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