Cod sursa(job #1396507)
Utilizator | Data | 22 martie 2015 17:01:49 | |
---|---|---|---|
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 fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,s;
int main(){
fin>>n>>p;
s=1;
while(p!=0){
if(p%2==1){
s=(s*n)%mod;
}
n=(n*n)%mod;
p/=2;
}
fout<<s<<"\n";
return 0;
}