forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathH.cpp
More file actions
56 lines (48 loc) · 1.47 KB
/
H.cpp
File metadata and controls
56 lines (48 loc) · 1.47 KB
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
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; ++i)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; --i)
#define REP(i,a) for(int i=0,_a=(a); i < _a; ++i)
#define DEBUG(X) { cout << #X << " = " << X << endl; }
#define PR(A,n) { cout << #A << " = "; FOR(_,1,n) cout << A[_] << ' '; cout << endl; }
#define PR0(A,n) { cout << #A << " = "; REP(_,n) cout << A[_] << ' '; cout << endl; }
#define sqr(x) ((x) * (x))
#define ll long long
#define SZ(x) ((int) (x).size())
using namespace std;
const int N = 100000;
ll f[N + 11][40];
int main() {
freopen("peaks.in", "r", stdin);
freopen("peaks.out", "w", stdout);
f[1][1] = 1;
for(int i=2; i<=N; i++) {
f[i][1] = (2*f[i-1][1]) % 239;
}
for(int j=2; j<=30; j++) {
for(int i=1; i<=N; i++)
f[i][j] = (2*j*f[i-1][j] + (i-2*j+2)*f[i-1][j-1]) % 239;
}
long long n, k;
while (cin >> n >> k) {
n = n % 56882;
while (n + 56882 < N) n += 56882;
cout << f[n][k] << endl;
}
return 0;
FOR(j,1,30) {
FOR(cycle,1,100000) {
bool good = true;
FORD(i,N,N-cycle*10) {
if (i < 0) assert(false);
if (f[i][j] != f[i-cycle][j]) {
good = false;
break;
}
}
if (good) {
cout << j << ' ' << cycle << endl;
break;
}
}
}
}