//moze bedzie 1 punkcik :-) #include<cstdio> main(){ char q[32]; unsigned long long w,ww,c=1,licznik=0,fib,fib1,fib2; fib2=0; fib1=1; gets(q); for(int i=0;q[i]>='0';i++)c*=10; sscanf(q,"%llu",&w); int i; for(i=2;i<10000000;i++) { fib=(fib2+fib1)%100000000000000000; fib2=fib1; fib1=fib; if(fib%c==w){printf("%d\n",i);break;} } if (i>=10000000)printf("NIE\n"); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | //moze bedzie 1 punkcik :-) #include<cstdio> main(){ char q[32]; unsigned long long w,ww,c=1,licznik=0,fib,fib1,fib2; fib2=0; fib1=1; gets(q); for(int i=0;q[i]>='0';i++)c*=10; sscanf(q,"%llu",&w); int i; for(i=2;i<10000000;i++) { fib=(fib2+fib1)%100000000000000000; fib2=fib1; fib1=fib; if(fib%c==w){printf("%d\n",i);break;} } if (i>=10000000)printf("NIE\n"); } |