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 <cstdio>
#include <cstring>

int main()
{
    long long k = 0, f_k = 0, f_kPlus1 = 1, ogon, pom, modul = 1;
    char ogon_napis[10];
    scanf("%s", ogon_napis);
    sscanf(ogon_napis, "%lld", &ogon);

    for (int i=0;i<strlen(ogon_napis); ++i)
    {
        modul *= 10;
    }

    while (true)
    {
        if (ogon == f_k)
        {
            printf("%lld\n", f_k);
            break;
        }
        else
        {
            fprintf(stderr, "%lld %lld %lld\n", k, f_k, f_kPlus1);
            ++k;
            pom = f_kPlus1;
            f_kPlus1 += f_k;
            f_kPlus1 %= modul;
            f_k = pom;
        }
    }
}