Cod sursa(job #2164571)
Utilizator | Data | 13 martie 2018 08:21:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n;
int p, x=1;
long long MOD=1999999973;
int main()
{
f >> n >> p;
while(p)
{
if( p%2 == 1 )
x = (x*n)%MOD;
n = (n*n)%MOD;
p /= 2;
}
g << x;
return 0;
}