Cod sursa(job #3339364)
| Utilizator | Data | 7 februarie 2026 16:23:02 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 30 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long power(long long baz, long long exp){
if(exp==0)
return 1;
long long half=power(baz,exp/2);
if(exp%2)
return half*half*baz%1999999973;
else
return half*half%1999999973;
}
int main()
{
long long n,p;
fin >> n >> p;
long long nr=power(n,p);
fout << nr;
return 0;
}
