Cod sursa(job #578088)
Utilizator | Data | 10 aprilie 2011 22:46:43 | |
---|---|---|---|
Problema | Al k-lea termen Fibonacci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include<fstream>
#define MOD 1999999973
using namespace std;
int a, b;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long putere(int b)
{
long long z;
if (b==0) return 1;
if (b==1) return a;
if (b%2==0)
{
z=putere(b/2);
z=(z*z) % MOD;
return z;
}
else
{
z=putere(b/2);
z=(((z*z) % MOD)*a) % MOD;
return z;
}
}
int main()
{
f>>a>>b;
a%=MOD;
g<<putere(b)<<"\n";
f.close();
g.close();
return 0;
}