Cod sursa(job #2608133)
Utilizator | Data | 30 aprilie 2020 17:23:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int nx=1999999973;
int main(){
unsigned long long int n,p,r=1;
in >>n>>p;
while(p){
if(p % 2 ==1){
r=(1LL*r*n) % nx;
}
n=(1ll*n*n) % nx;
p=p/2;
}
out<<r;
}