Cod sursa(job #971205)
| Utilizator | Data | 8 iulie 2013 18:44:25 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
| 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");
int N,P;
unsigned long long Sol;
int main ( void )
{
f>>N>>P;
Sol=1;
while ( P )
{
if( P&1 )
Sol=(SOL*N)%MOD;
N=(N*N)%MOD;
P=P>>1;
}
g<<Sol%MOD;
f.close();
g.close();
}