#include <iostream> #include <cstdio> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <vector> #include <utility> #include <string> #include <math.h> using namespace std; int main(){ char string[20]; scanf("%s", string); char* str = string; unsigned long long number = atol(str); int length = strlen(string); unsigned long long numbers = (unsigned long long)(pow( 10, length )); unsigned long long a = 0; unsigned long long b = 1; unsigned long long c = 0; for(unsigned long long k = 2 ; k < 15000000; ++k){ c = a + b; a = b; b = c; if(c > 1000000000000000000){ c = c % 1000000000000000000; b = b % 1000000000000000000; a = a % 1000000000000000000; } if((c % numbers) - number == 0){ printf("%llu ", k); return 0; } } printf("%s", "NIE"); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | #include <iostream> #include <cstdio> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <vector> #include <utility> #include <string> #include <math.h> using namespace std; int main(){ char string[20]; scanf("%s", string); char* str = string; unsigned long long number = atol(str); int length = strlen(string); unsigned long long numbers = (unsigned long long)(pow( 10, length )); unsigned long long a = 0; unsigned long long b = 1; unsigned long long c = 0; for(unsigned long long k = 2 ; k < 15000000; ++k){ c = a + b; a = b; b = c; if(c > 1000000000000000000){ c = c % 1000000000000000000; b = b % 1000000000000000000; a = a % 1000000000000000000; } if((c % numbers) - number == 0){ printf("%llu ", k); return 0; } } printf("%s", "NIE"); return 0; } |