Cod sursa(job #1368173)
Utilizator | Data | 2 martie 2015 14:54:01 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
int main()
{
ifstream in("kfib.in");
ofstream out("kfib.out");
long long a;
long long b;
in >> a;
b = 666013;
a %= 1332028;
long long x1 = 1, x2 = 1;
for (int i = 3; i <= a; ++i)
{
x2 = x1 + x2;
x1 = x2 - x1;
x2 %= b;
}
out << x2 << '\n';
return 0;
}