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