Cod sursa(job #1396505)
Utilizator | Data | 22 martie 2015 17:01:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
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");
int 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;
}