Cod sursa(job #1593235)

Utilizator tothalToth Alexandru tothal Data 8 februarie 2016 14:05:24
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.29 kb
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{int n,p,sol=1;
    fin>>n>>p;
    while(p)
    {
        if(p&1)
            sol*=n%mod;
        n*=n%mod;
        p=p>>1;
    }
    fout<<sol;
}