-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11977 - Story of Tomisu Ghost.cpp
74 lines (67 loc) · 2.65 KB
/
11977 - Story of Tomisu Ghost.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/******************************************************************************
* ▄██████████▄ ▀█████████▄ ▀██████████▄ ▄████████████▄ ▄██████████▄ *
* ▀▀███ ███▀ ███ ███ ███ ▀██▄ ▀███▀ ▀███▀ █▀ ▄███▀ *
* ███ ███ ███ ██ ███ ███ ▄███▀ *
* ▄███▄▄▄██▀ ▄███▄▄▄██▀ ███ ██▀ ███ ███ ▄███▀ *
* ▀▀███▀▀▀██▄ ▀▀███▀▀▀██▄ ▄███▄▄▄▄▄██▀ ███ ███ ▄███▀ *
* ███ ███ ▀▀███▀▀▀▀▀██▄ ███ ███ ▄███▀ *
* ███ ███ ███ ███ ███ ▄███▄ ▄███▄ ▄███▀ ▄█ *
* ▄▄████▀ ▄█████████▀ ▄███ ███▄ ▀████████████▀ ▀██████████▀ *
* *
* *Don't limit your challenges, challenge your limits. *
******************************************************************************/
#include <stdio.h>
#include <bits/stdc++.h>
#define MAX 100490
#define MOD 10000019
using namespace std;
const int N = 1000005;
bool P[MAX];
long long bigmod(long long n, long long p) {
if(p == 0) return 1;
else if(p & 1) return (n * bigmod(n, p - 1)) % MOD;
else {
long long x = bigmod(n, p / 2);
return (x * x) % MOD;
}
}
void seive(){
memset(P,true,sizeof(P));
P[1] = false;
for(int i=2; i<=317; i++)
if(P[i])
for(int j=i*i; j<=MAX; j+=i)
P[j] = false;
}
void init(){
seive();
int tc,T,n,t;
long long res,cnt,divi;
bool possible;
scanf("%d",&T);
for(int tc=1; tc <= T; tc++){
scanf("%d%d",&n,&t);
res = 1;
possible = false;
for(int m=2; m<=n; m++)
if(P[m]){
cnt = 0, divi = m;
while(divi <= n){
cnt += n/divi;
divi *= m;
}
if(cnt >= t) possible = true;
res = (res*bigmod(m,cnt/t))%MOD;
}
if(possible) printf("Case %d: %lld\n",tc,res);
else printf("Case %d: -1\n",tc);
}
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
init();
return 0;
}