Cod sursa(job #1649219)
| Utilizator | Data | 11 martie 2016 12:51:54 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long putere(long long x, long long y)
{
int r=1;
while(y)
{
if(y%2==1)
{
r=(r*x)%mod;
y--;
}
x=(x*x)%mod;
y=y/2;
}
return r;
}
int main()
{
int n, m;
cin>>n>>m;
cout<<putere(n, m);
fin.close();
fout.close();
return 0;
}
