Cod sursa(job #2045927)
| Utilizator | Data | 23 octombrie 2017 08:47:08 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.64 kb |
#include <fstream>
#include <iostream>
#include <stdio.h>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
#define MAX 1999999973
long long power(long long x,long long power)
{
long long res = 1;
while(power > 0)
{
if(power & 1)
res = (res*x)%MAX;
power = power >> 1;
x = (x*x) % MAX;
}
return res;
}
int main()
{
FILE* f = fopen("lgput.in","r");
FILE* g = fopen("lgput.out","w");
long long a,b;
fscanf(f,"%lld %lld",&a,&b);
fprintf(g, "%lld\n", power(a,b));
return 0;
}
