#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
int main()
{
long long int a=1; long long int b=1; string tempnumber; long long int number; int length=0; long long int temp; long long int k=0;
cin >> tempnumber;
length=tempnumber.length();
number=strtoll(tempnumber.c_str(), NULL, 10);
if(tempnumber=="0" || tempnumber=="1")
{
cout << tempnumber;
return 0;
}
k=2;
while(k<pow(10, 6))
{
temp=a;
a=a+b;
b=temp;
k++;
if(a>=pow(10, length))
a=a-pow(10, length)+1;
if(a==number)
{
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 | #include <iostream> #include <stdlib.h> #include <math.h> using namespace std; int main() { long long int a=1; long long int b=1; string tempnumber; long long int number; int length=0; long long int temp; long long int k=0; cin >> tempnumber; length=tempnumber.length(); number=strtoll(tempnumber.c_str(), NULL, 10); if(tempnumber=="0" || tempnumber=="1") { cout << tempnumber; return 0; } k=2; while(k<pow(10, 6)) { temp=a; a=a+b; b=temp; k++; if(a>=pow(10, length)) a=a-pow(10, length)+1; if(a==number) { cout << k; return 0; } } cout << "NIE"; return 0; } |
English