Cod sursa(job #2702107)
Utilizator | Data | 2 februarie 2021 21:55:35 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 20 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("kfib.in");
ofstream out("kfib.out");
int main()
{
long long f1,f2,f,k,ct,i;
in>>k;
f1=1;
f2=1;
if(k==1||k==2) out<<1;
else{
for(i=3;i<=k;i++){
f=(f1+f2)%666013;
f1=f2;
f2=f;
}
out<<f;
}
return 0;
}