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