Cod sursa(job #1593236)
Utilizator | Data | 8 februarie 2016 14:08:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{long long n,p,sol=1;
fin>>n>>p;
while(p)
{
if(p&1)
sol=(sol*n)%mod;
n=(n*n)%mod;
p=p>>1;
}
fout<<sol;
}