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
47
48
49
50
51
52
53
54
55
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

long long a, b=0, c=1, okr, i, mod, wzor=0;

long long potega10 (short int x)
{
    long long pot=1;
    for (short int k=0; k<x; k++)
        pot*=10;
    return pot;
}

int main()
{
    char ciag[20];
    scanf ("%s", ciag);
    short int l=strlen (ciag);
    switch (l)
    {
        case 1:
            okr=60;
            break;
        case 2:
            okr=300;
            break;
        default:
            okr=15*potega10 (l-1);
            break;
    }
    for (short int j=l-1; j>=0; j--)
    {
        wzor+=(ciag[j]-'0')*potega10 (l-1-j);
    }
    mod=pow (10, l);
    for (i=2; i<okr+2&&c!=wzor; i++)
    {
        a=b;
        b=c;
        c=(a+b)%mod;
    }
    i--;
    if (c==wzor)
    {
        if (ciag[0]=='0'&&c<mod)
            i+=okr;
        printf ("%lld", i);
    }
    else
        printf ("NIE");
    return 0;
}