Cod sursa(job #2118544)
Utilizator | Data | 30 ianuarie 2018 18:57:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int n, m, p, x=1;
long long MOD=1999999973;
int main()
{
f >> n >> p;
while (p!=0)
{
if( p%2 == 1 )
x = (x*n)%MOD;
n = (n*n)%MOD;
p/=2;
}
g << x;
return 0;
}