Cod sursa(job #2027339)
Utilizator | Data | 25 septembrie 2017 22:03:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int modulo=1999999973;
const int nmax=(1<<32);
///Complexitate log(m)
int n,m;
int main()
{
int sol=1;
fin>>n>>m;
while(m)
{
if(m%2)
sol=1LL*sol*n%modulo;
m/=2;
n=1LL*n*n%modulo;
}
fout<<sol<<"\n";
fin.close();
fout.close();
return 0;
}