Cod sursa(job #1966490)
Utilizator | Data | 15 aprilie 2017 12:20:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include<bits/stdc++.h>
# define mod 1999999973
using namespace std;
long long r=1, n, p, s;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>n>>p;
s=n;
while(p)
{
if((p&1))
{
r=r*s;
r=r%mod;
}
s=s*s;
s=s%mod;
p=(p>>1);
}
g<<r<<'\n';
return 0;
}