#include <iostream>
#include <stdlib.h>
#include <string>
using namespace std;
typedef long long int int64;
int main()
{
string c;
cin >> c;
int64 cInt;
sscanf( c.c_str(), "%lld", &cInt );
int64 div = 1;
while ( div < cInt )
{
div *= 10;
}
int64 zeros = 1;
for ( int i = 0; i < c.length() && c[ i ] == '0'; ++i )
{
zeros *= 10;
}
const int LIMIT = 1000000;
int a = 0;
int b = 1;
for ( int k = 2; k < LIMIT; ++k )
{
const int64 c = ( a + b ) % LIMIT;
a = b;
b = c;
if ( c % div == cInt && ( c / div ) % zeros == 0 )
{
cout << k;
return 0;
}
}
cout << "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 | #include <iostream> #include <stdlib.h> #include <string> using namespace std; typedef long long int int64; int main() { string c; cin >> c; int64 cInt; sscanf( c.c_str(), "%lld", &cInt ); int64 div = 1; while ( div < cInt ) { div *= 10; } int64 zeros = 1; for ( int i = 0; i < c.length() && c[ i ] == '0'; ++i ) { zeros *= 10; } const int LIMIT = 1000000; int a = 0; int b = 1; for ( int k = 2; k < LIMIT; ++k ) { const int64 c = ( a + b ) % LIMIT; a = b; b = c; if ( c % div == cInt && ( c / div ) % zeros == 0 ) { cout << k; return 0; } } cout << "NIE"; return 0; } |
English