|
|
back to boardWrong answer. Why? #include <stdio.h> unsigned long get_an(unsigned long n); int main(){ unsigned long n[10],i; for(i=0; ; ++i){ scanf("%ld", &n[i]); if(!n[i]) break; n[i]=get_an(n[i]+n[i]%2-1); } for(i=0; n[i]; ++i) printf("%ld\n", n[i]); return 0; } unsigned long get_an(unsigned long n){ if(n==1) return 1; if(n%2) return ( get_an((n-1)/2)+get_an((n-1)/2+1) ); else return get_an(n/2); } |
|
|