Pagini recente » Cod sursa (job #699595) | Atasamentele paginii Profil toni123 | Cod sursa (job #2297993) | Cod sursa (job #2275583) | Cod sursa (job #970535)
Cod sursa(job #970535)
#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 % m,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*x, n/2);
else if (n % 2 != 0) return x * Functionexpbysquaring(x*x, (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, p);
fprintf(g, "%lld", sol % m);
fclose(f);
fclose(g);
return 0;
}