#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
unsigned long long int n;
cin >> n;
if (n<=1)
{
cout << n;
return 0;
}
unsigned long long a=1, b=1, c, mod=10;
while (mod<=n)
mod*=10;
//cout << mod << " ";
for (int i=3; i<=10000000; i++)
{
c=a+b;
c%=mod;
//cout << c << "\n";
if (c==n)
{
cout << i << "\n";
return 0;
}
a=b;
b=c;
}
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 | #include <iostream> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(0); unsigned long long int n; cin >> n; if (n<=1) { cout << n; return 0; } unsigned long long a=1, b=1, c, mod=10; while (mod<=n) mod*=10; //cout << mod << " "; for (int i=3; i<=10000000; i++) { c=a+b; c%=mod; //cout << c << "\n"; if (c==n) { cout << i << "\n"; return 0; } a=b; b=c; } cout << "NIE"; return 0; } |
English