Cod sursa(job #1904457)
Utilizator | Data | 5 martie 2017 16:05:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
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");
int 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;}