Cod sursa(job #832139)
| Utilizator | Data | 9 decembrie 2012 22:05:21 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.27 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{
long long n,p;
f>>n>>p;
long long rez=1;
while(p)
{
if(p%2==1)
rez=(rez*n)%mod;
n=(n*n)%mod;
p/=2;
}
g<<rez;
}
