Cod sursa(job #2765958)
| Utilizator | Data | 30 iulie 2021 16:02:39 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <stdio.h>
#include <stdlib.h>
FILE *f,*g;
const long long Mod = 1999999973;
long long n,p;
long long putere(long long b,long long e)
{
if(e==0)
return 1;
long long r = putere(b,e/2);
r=r*r%Mod;
if(e%2==1)
r=r*b%Mod;
return r;
}
int main()
{
f=fopen("lgput.in","r");
g=fopen("lgput.out","w");
fscanf(f,"%lld%lld",&n,&p);
n%=Mod;
fprintf(g,"%lld",putere(n,p));
return 0;
}
