Cod sursa(job #1219098)
Utilizator | Data | 13 august 2014 14:02:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include<fstream>
using namespace std;
ifstream fin( "lgput.in" );
ofstream fout( "lgput.out" );
const int mod = 1999999973;
int main() {
long long sol, n, p;
fin>>n>>p;
sol = 1;
while ( p > 0 ) {
if ( p % 2 == 1 ) {
sol *= n;
sol %= mod;
}
p /= 2;
n *= n;
n %= mod;
}
fout<<sol<<'\n';
fin.close();
fout.close();
return 0;
}