Cod sursa(job #3132578)
Utilizator | Data | 23 mai 2023 10:19:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include<bits/stdc++.h>
using namespace std;
const int modul= 1999999973;
int putere(int N,int P)
{
int rest=1;
while(P)
{
if(P%2!=0)
rest=(1LL*rest*N)%modul;
N=(1LL*N*N)%modul;
P=P/2;
}
return rest;
}
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
int N,P;
f>>N>>P;
g<<putere(N,P);
}