Cod sursa(job #1908131)
Utilizator | Data | 6 martie 2017 22:55:18 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <algorithm>
#include <iostream>
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{
long long n, p, x = 1;
f >> n >> p;
while(p)
{
if(p & 1) x = (x * n) % mod;
n = (n * n) % mod;
p >>= 1;
}
g << x;
}