Cod sursa(job #3365138)
| Utilizator | Data | 17 septembrie 2026 11:42:59 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
/// #include <bits/stdc++.h>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int MOD = 1999999973;
int putere(int b,int e)
{
if(e==0)
return 1;
if(e%2==0)
{
int r=putere(b,e/2);
r=1LL*r*r%MOD;
return r;
}
return 1LL*putere(b,e-1)*b%MOD;
}
int main()
{
int n,p;
f>>n>>p;
g<<putere(n,p)<<'\n';
return 0;
}
