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