Cod sursa(job #1464088)

Utilizator stefanchistefan chiper stefanchi Data 22 iulie 2015 11:59:48
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.51 kb
#include <iostream>
#include <fstream>
#define Mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,x;
int rid(long long , long long p)
{
    long long x = 1;
    while(p > 0)
    {
        if ( p % 2 == 1 )
        {
            x = x * n % Mod;
            p --;
        }
        else
        {
          p = p / 2 ;
          n = n * n % Mod;
        }

    }
    return x;
}
int main()
{
    fin>>n>>p;
    fout<<rid(n,p);
    return 0;
}