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