Cod sursa(job #1784397)
Utilizator | Data | 19 octombrie 2016 23:38:29 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 20 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <stdio.h>
using namespace std;
int main() { //metoda bruta <3
freopen("kfib.in", "r", stdin);
freopen("kfib.out", "w", stdout);
int x;
cin >> x;
int past = 0, present = 1, future = 1;
for (int i = 2; i <= x; i++) {
past = present;
present = future;
future = (present + past) % 666013;
}
cout << present;
}