Cod sursa(job #2929761)
| Utilizator | Data | 26 octombrie 2022 20:05:01 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <iostream>
#include <fstream>
using namespace std;
# define Mod 1999999973
int putere(int a, int n){
if(n%2==0)
return((long long )( putere(a,n/2)% Mod)*(putere(a,n/2)% Mod))%Mod;
else if(n%2==1 && n!=1)
return (((long long )(putere(a,n/2)%Mod)*(putere(a,n/2)%Mod))%Mod*(a%Mod))%Mod;
else return a%Mod;
}
int main()
{
ifstream in("lgput.in");
ofstream out("lgput.out");
int n, a, i;
in>>a>>n;
out<<putere(a, n);
return 0;
}
