Pagini recente » Cod sursa (job #680181) | Monitorul de evaluare | Cod sursa (job #3339109) | Cod sursa (job #2886622) | Cod sursa (job #970536)
Cod sursa(job #970536)
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string.h>
#include <stdlib.h>
using namespace std;
#define NMax 100000
const int m = 1999999973;
long long int Functionexpbysquaring(long long int x,long long int n)
{
if (n < 0) return Functionexpbysquaring(1/x,-n);
else if (n == 0) return 1;
else if (n == 1) return x;
else if (n % 2 == 0) return Functionexpbysquaring(((x % m)*(x % m) % m), n/2);
else if (n % 2 != 0) return (x % m) * Functionexpbysquaring(((x % m)*(x % m)) % m), (n-1)/2);
}
int main()
{
long long int i, n, p;
long long int sol;
FILE *f = fopen("lgput.in", "r");
FILE *g = fopen("lgput.out", "w");
fscanf(f, "%lld %lld", &n, &p);
sol = Functionexpbysquaring((n%m), p);
fprintf(g, "%lld", sol % m);
fclose(f);
fclose(g);
return 0;
}