Cod sursa(job #1092406)
| Utilizator | Data | 26 ianuarie 2014 23:21:41 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <cstdio>
#define IN "lgput.in"
#define OUT "lgput.out"
#define MODUL 1999999973
using namespace std;
long long int t,k;
long long int putere(int a, int x)
{
if(x==0) return 1;
int y=putere(a,x/2)%MODUL;
if(x%2==0) return (y*y)% MODUL;
else return (( (y*a)%MODUL)*y)% MODUL;
}
void citire()
{
FILE*fin=fopen(IN,"r");
FILE*fout=fopen(OUT,"w");
long long int i,x;
fscanf(fin,"%d %d",&t,&k);
fprintf(fout,"%lld\n",putere(t%MODUL,k)%MODUL);
}
int main()
{
citire();
return 0;
}
