Mai intai trebuie sa te autentifici.
Cod sursa(job #2175348)
Utilizator | Data | 16 martie 2018 16:47:28 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
#define mod 1999999973
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
int main()
{
long long numar = 1 , n, p;
f >> n >> p;
while(p)
{
if(p % 2 == 0)
n = (n * n) % mod, p /= 2;
else numar = (1LL*numar * n) % mod, p--;
}
g << numar;
return 0;
}