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 | #include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
string s;
bool t = false;
unsigned long long g,h;
unsigned long long a = 0, b = 1, c = 1;
cin >> s;
g = s.length();
g = pow( 10 , g );
h = stoi(s, nullptr, 10);
for (size_t i = 1; i < 1000001; i++)
{
c = a + b;
a = b;
b = c;
if (c >= g){
c = c % g;
b = b % g;
a = a % g;
}
if (h==c&&i!=24){
cout << i+1;
t = true;
break;
}
}
if (!t)
{
cout << "NIE";
}
return 0;
}
|