Cod sursa(job #971203)
Utilizator | Data | 8 iulie 2013 18:43:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include<fstream>
#define MOD 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int N,P;
unsigned long long Sol;
int main ( void )
{
f>>N>>P;
Sol=1;
while ( P )
{
if( P&1 )
Sol=((Sol%MOD)*(N%MOD))%MOD;
N=(N*N)%MOD;
P=P>>1;
}
g<<Sol%MOD;
f.close();
g.close();
}