Cod sursa(job #1412451)
Utilizator | Data | 1 aprilie 2015 12:06:50 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include<cstdio>
#define mod 1999999973
using namespace std;
int n,m;
int putere(int x,int y)
{
int s=1;
while(y>0)
{
if(y&1)s=s*x%mod;
x=x*x%mod;
y>>=1;
}
return s;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d %d",&n,&m);
printf("%d",putere(n,m));
return 0;
}