Cod sursa(job #1436973)
| Utilizator | Data | 16 mai 2015 18:04:05 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int n,p;
int main(){
fin>>n>>p;
int sol=1;
while(p){
if(p%2) sol=(sol*n)%mod;
n=(n*n)%mod;
p/=2;
}
fout<<sol<<'\n';
return 0;
}
