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
#include <iostream>
#include <math.h>
using namespace std;

unsigned long long int c, a, b, tmp, n;

int main(){
	ios_base::sync_with_stdio(0);
	cin >> c;
	for(n = 1; n <= 18; ++n){
		if(c < pow(10, n)) break;
	}
	n = pow(10, n);
	if(c == 1){
		cout << 1 << endl; return 0;
	}
	a = 1;
	b = 0;
	for(unsigned long long int i = 2; i <= 70000000; ++i){
		tmp = a;
		a = (a+b)%n;
		b = tmp;
		//cout << i << ": " << a << endl;
		if(a == c){
			cout << i << endl;
			return 0;
		}
	}
	cout << "NIE" << endl;
	return 0;
}