Cod sursa(job #2443252)
| Utilizator | Data | 27 iulie 2019 11:00:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int putere(long long n,long long p)
{
long long r = 1;
while(p > 0)
{
if(p % 2 == 1)
r = (r * n) % MOD;
n = (n * n) % MOD;
p = p / 2;
}
return r;
}
long long n,p;
int main()
{
fin>>n>>p;
fout<<putere(n,p) % MOD;
return 0;
}
