Cod sursa(job #968445)

Utilizator Johny_Depp22Johnny Depp Johny_Depp22 Data 2 iulie 2013 01:42:23
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.32 kb
#include <fstream>
#define mod 1999999973

using namespace std;

ifstream f("lgput.in");
ofstream g("lgput.out");

unsigned long long n, k, res=1;

int main()
{
    f>>n>>k;

    while(k>0)
    {
        if(k%2==1) res*=n, res%=mod;
        n*=n; n%=mod; k/=2;
    }
    g<<res<<'\n';
    return 0;
}