Cod sursa(job #1472489)
Utilizator | Data | 17 august 2015 09:57:48 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include<fstream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int x,y;
long long exp(int x,int y)
{
if(y==0)
return 1;
else if(y%2==1)
return (x%mod)*(exp(x,y-1)%mod)%mod;
else
{
long long p2;
p2=exp(x,y/2)%mod;
return (p2%mod)*(p2%mod)%mod;
}
}
int main()
{
f>>x>>y;
g<<exp(x,y);
return 0;
}