Cod sursa(job #2140658)

Utilizator Steve_ITStefan Ursache Steve_IT Data 23 februarie 2018 19:11:32
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long rid(long long a, long long b) {
    if(b == 0) return 1;
    long long x = rid(a, b/2);
    if (b%2 == 0)
        return x * x % 1999999973;
    else return (x * x % 1999999973) * a % 1999999973;
}
int n, p;
int main() {
    f>>n>>p;
    g<<rid(n, p);
    return 0;
}