Cod sursa(job #936515)
Utilizator | Data | 7 aprilie 2013 14:52:04 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include<cstdio>
using namespace std;
long long x=0LL,y=1LL,z=0LL,k=0LL,n=0LL;
int main()
{
freopen("fibo.in","r",stdin);
scanf("%lld%lld",&k,&n);
while(k>0)
{
z=(x+y)%n;
x=y;
if(z==(2*n))
x=1,y=1;
y=z;
k--;
}
freopen("fibo.out","w",stdout);
printf("%lld\n",x);
}