Cod sursa(job #2332733)
Utilizator | Data | 31 ianuarie 2019 10:00:40 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.63 kb |
#include <iostream>
#include <fstream>
#include <climits>
#define mod 1999999973
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
long long n,p,rez=1;
long long inm(long long x,long long y)
{
long long cont=1,sol=1;
while(cont<=y)
{
sol=(sol*x)%mod;
cont++;
}
return sol;
}
int main()
{
in>>n>>p;
long long pt=inm(n,1000),cont=1000;
while(cont<=p)
{
rez=(rez*pt)%mod;
cont+=1000;
}
if(cont>p)cont=1,rez=1;
while(cont<=p)
{
rez=(rez*n)%mod;
cont++;
}
out<<rez;
return 0;
}