Cod sursa(job #1092397)

Utilizator robertc1Robert Ciobotaru robertc1 Data 26 ianuarie 2014 23:08:36
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
#include <fstream>
#define IN "lgput.in"
#define OUT "lgput.out"
#define MODUL 1999999973
using namespace std;

ifstream fin(IN);
ofstream fout(OUT);

long long int t,k;

long long int putere(int k, int x)
{
    if(x==0) return 1;
    int y=putere(k,x/2)%MODUL;
    if(x%2==0) return  (y*y)% MODUL;
        else return (( (y*y)%MODUL)*k)% MODUL;
}
void citire()
{
    long long int i,x;
    fin>>t>>k;
    fout<<putere(t,k)%MODUL<<'\n';
}
int main()
{
    citire();
    return 0;
}