Pagini recente » Cod sursa (job #1148221) | Cod sursa (job #1948553) | Cod sursa (job #2310534) | Cod sursa (job #2422322) | Cod sursa (job #3239770)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("kfib.in");
ofstream fout("kfib.out");
const int mod = 666013;
long long r[2][2] = {{1, 0}, {0, 1}};
long long f[2][2] = {{0, 1}, {1, 1}};
long long k;
static inline void Prod(long long a[2][2], long long b[2][2]) {
long long c[2][2] = {{0, 0}, {0, 0}};
for(int i : {0, 1}) {
for(int j : {0, 1}) {
for(int k : {0, 1}) c[i][j] += a[i][k] * b[k][j];
}
}
for(int i : {0, 1}) {
for(int j : {0, 1}) a[i][j] = c[i][j] % mod;
}
}
static inline void Put(long long k) {
while(k) {
if(k & 1) Prod(r, f);
Prod(f, f);
k >>= 1;
}
}
int main() {
fin >> k;
Put(k - 1);
fout << r[1][1];
return 0;
}