QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#182003#4908. 完全表示zhoukangyang85 263ms36912kbC++113.2kb2023-09-17 08:56:332023-09-17 08:56:33

Judging History

你现在查看的是最新测评结果

  • [2023-09-17 08:56:33]
  • 评测
  • 测评结果:85
  • 用时:263ms
  • 内存:36912kb
  • [2023-09-17 08:56:33]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long 
#define vi vector < int > 
#define sz(a) ((int) (a).size())
#define ll long long 
#define ull unsigned long long
#define me(a, x) memset(a, x, sizeof(a)) 
using namespace std;
const int N = 1 << 19, mod = 164511353;
int qpow(int x, int y = mod - 2) {
	int res = 1;
	for(; y; x = (ll) x * x % mod, y >>= 1) if(y & 1) res = (ll) res * x % mod;
	return res;
}
int fac[N], ifac[N], inv[N];
void init(int x) {
	fac[0] = ifac[0] = inv[1] = 1;
	L(i, 2, x) inv[i] = (ll) (mod - mod / i) * inv[mod % i] % mod;
	L(i, 1, x) fac[i] = (ll) fac[i - 1] * i % mod, ifac[i] = (ll) ifac[i - 1] * inv[i] % mod;
} 
int C(int x, int y) {
	return x < y || y < 0 ? 0 : (ll) fac[x] * ifac[y] % mod * ifac[x - y] % mod;
}
inline int sgn(int x) {
	return (x & 1) ? mod - 1 : 1;
}

const int r = 41;
int n, k, m, type;
int prm[N], mt[N], rmt[N], cnt[N], top;
int sum[N];
int fen[N];
int val[N];

template < int N > struct deq {
	int L, R;
	int dp[N][41];
	int stk[N], top;
	deq() {
		L = 0, R = -1;
		me(dp[0], 0), dp[0][1] = 1;
	}
	void undo() {
		--top;
	}
	
	int ndp[41];
	void pb(int x) {
		stk[++top] = x;
		memcpy(dp[top], dp[top - 1], sizeof(dp[top]));
		L(i, 1, ::top) {
			int A = mod - qpow(prm[i], x + mod - 1);
			int m1 = mt[i] % 41, m2 = rmt[i] % 41;
			me(ndp, 0);
			L(j, 0, 40) {
				(ndp[m1 * j % 41] += (ll)A * dp[top][j] % mod) %= mod;
				(ndp[m2 * j % 41] += dp[top][j]) %= mod;
			} 
			swap(ndp, dp[top]);
		}
	}
	void move(int l, int r) {
		if(L > R) L = l, R = l - 1;
		// assert(L <= l && R <= r) 
		R(i, r, R + 1) pb(i);
		R = r;
		int tmp = 0;
		vi Z;
		int cnt = 0;
		while(tmp != l - L) Z.emplace_back(stk[top]), tmp += stk[top] < l, undo(), ++cnt;
		while(top && cnt--) Z.emplace_back(stk[top]), undo();
		sort(Z.begin(), Z.end());
		R(i, sz(Z) - 1, 0) if(Z[i] >= l) pb(Z[i]);
		L = l;
	}
} ;
deq < N > T;

int main() {
	ios :: sync_with_stdio(false); 
	cin.tie(0); cout.tie(0);
	init(N - 10);
	cin >> n >> k >> m;
	cin >> type;
	if(type == 1) {
	
	L(i, 2, k) if(k % i == 0) {
		int c = 0;
		while(k % i == 0) k /= i, ++c;
		++top, prm[top] = i, cnt[top] = c, mt[top] = rmt[top] = 1;
		L(j, 1, c) mt[top] *= i;
		L(j, 1, c - 1) rmt[top] *= i;
	} 
	
	L(c, 0, m) {
	T.move(c - n + 1, c);
	int MUL = 1;
	L(i, 1, top) 
		MUL = (ll) MUL * qpow(qpow(rmt[i], c), n) % mod * 
			qpow(prm[i], (ll)n * (n - 1) / 2 % (mod - 1)) % mod * sgn(n) % mod;
	L(x, 0, 40) {
		int pr = (ll)T.dp[T.top][x] * qpow(2, x) % mod;
		(sum[c] += pr) %= mod;
	}
	sum[c] = (ll) sum[c] * MUL % mod;
	}
	
	vi mul(m + 1);
	mul[0] = 1;
	L(i, 0, m) {
		if(i) {
			R(j, i - 1, 0) {
				(mul[j + 1] += mul[j]) %= mod;
				mul[j] = (ll) mul[j] * (mod - (i - 1)) % mod;
			}
		}
		L(j, 0, i) {
			(fen[i] += (ll) mul[j] * sum[j] % mod) %= mod;
		}
	}
	
	L(i, 0, m) 
		fen[i] = (ll)fen[i] * qpow(qpow(2), i) % mod * ifac[i] % mod; 
	L(i, 0, m) {
		L(j, 0, i) {
			(val[j] += (ll)fen[i] * sgn(i - j) % mod * C(i, j) % mod) %= mod;
		}
	}
	
	int ANS = 0;
	L(i, 0, m) {
		(ANS += (ll)val[i] * qpow(i, m) % mod) %= mod;
	}
	cout << ANS << '\n';
	
	}
	return 0;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 6ms
memory: 20088kb

input:

2 3 665
1

output:

51745605

result:

ok "51745605"

Test #2:

score: 0
Accepted
time: 9ms
memory: 18876kb

input:

2 4 641
1

output:

54153482

result:

ok "54153482"

Test #3:

score: 0
Accepted
time: 9ms
memory: 18284kb

input:

1 6 656
1

output:

119347748

result:

ok "119347748"

Test #4:

score: 0
Accepted
time: 4ms
memory: 19396kb

input:

1 8 170
1

output:

126971959

result:

ok "126971959"

Test #5:

score: 0
Accepted
time: 10ms
memory: 18416kb

input:

1 9 816
1

output:

14287284

result:

ok "14287284"

Test #6:

score: 0
Accepted
time: 6ms
memory: 19752kb

input:

1 12 233
1

output:

37178137

result:

ok "37178137"

Test #7:

score: 0
Accepted
time: 8ms
memory: 19880kb

input:

1 16 244
1

output:

91022688

result:

ok "91022688"

Test #8:

score: 0
Accepted
time: 0ms
memory: 19088kb

input:

1 18 218
1

output:

93037058

result:

ok "93037058"

Test #9:

score: 0
Accepted
time: 11ms
memory: 19768kb

input:

1 19 645
1

output:

53944276

result:

ok "53944276"

Test #10:

score: 0
Accepted
time: 4ms
memory: 19064kb

input:

1 20 333
1

output:

81197702

result:

ok "81197702"

Test #11:

score: 0
Accepted
time: 15ms
memory: 18844kb

input:

1 2 893
1

output:

17672119

result:

ok "17672119"

Test #12:

score: 0
Accepted
time: 10ms
memory: 18376kb

input:

1 19 887
1

output:

58567516

result:

ok "58567516"

Test #13:

score: 0
Accepted
time: 10ms
memory: 19288kb

input:

2 3 504
1

output:

60763909

result:

ok "60763909"

Subtask #2:

score: 15
Accepted

Test #14:

score: 15
Accepted
time: 3ms
memory: 18240kb

input:

19 90203 0
1

output:

142145213

result:

ok "142145213"

Test #15:

score: 0
Accepted
time: 8ms
memory: 18116kb

input:

18 9697 0
1

output:

153592927

result:

ok "153592927"

Test #16:

score: 0
Accepted
time: 4ms
memory: 19596kb

input:

20 41 0
1

output:

112957727

result:

ok "112957727"

Test #17:

score: 0
Accepted
time: 4ms
memory: 18908kb

input:

20 99991 0
1

output:

151341559

result:

ok "151341559"

Subtask #3:

score: 5
Accepted

Dependency #2:

100%
Accepted

Test #18:

score: 5
Accepted
time: 8ms
memory: 18796kb

input:

999 9749 0
1

output:

77370298

result:

ok "77370298"

Test #19:

score: 0
Accepted
time: 9ms
memory: 18088kb

input:

997 55103 0
1

output:

92054017

result:

ok "92054017"

Test #20:

score: 0
Accepted
time: 4ms
memory: 22084kb

input:

1000 41 0
1

output:

6438830

result:

ok "6438830"

Test #21:

score: 0
Accepted
time: 4ms
memory: 22312kb

input:

1000 99991 0
1

output:

31676606

result:

ok "31676606"

Subtask #4:

score: 5
Accepted

Dependency #3:

100%
Accepted

Test #22:

score: 5
Accepted
time: 39ms
memory: 36576kb

input:

99996 20089 0
1

output:

163612442

result:

ok "163612442"

Test #23:

score: 0
Accepted
time: 36ms
memory: 36452kb

input:

99996 17707 0
1

output:

109099283

result:

ok "109099283"

Test #24:

score: 0
Accepted
time: 42ms
memory: 34364kb

input:

100000 41 0
1

output:

131161322

result:

ok "131161322"

Test #25:

score: 0
Accepted
time: 40ms
memory: 36608kb

input:

100000 99991 0
1

output:

84487741

result:

ok "84487741"

Subtask #5:

score: 15
Accepted

Test #26:

score: 15
Accepted
time: 3ms
memory: 19448kb

input:

998 24 0
1

output:

75129854

result:

ok "75129854"

Test #27:

score: 0
Accepted
time: 4ms
memory: 19560kb

input:

998 35 0
1

output:

120341894

result:

ok "120341894"

Test #28:

score: 0
Accepted
time: 4ms
memory: 22248kb

input:

1000 30 0
1

output:

152799538

result:

ok "152799538"

Test #29:

score: 0
Accepted
time: 9ms
memory: 19808kb

input:

1000 82 0
1

output:

117109540

result:

ok "117109540"

Test #30:

score: 0
Accepted
time: 9ms
memory: 18556kb

input:

1000 100 0
1

output:

89805014

result:

ok "89805014"

Subtask #6:

score: 5
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #31:

score: 5
Accepted
time: 112ms
memory: 36352kb

input:

99998 20726 0
1

output:

63876769

result:

ok "63876769"

Test #32:

score: 0
Accepted
time: 151ms
memory: 36912kb

input:

99998 10270 0
1

output:

47691333

result:

ok "47691333"

Test #33:

score: 0
Accepted
time: 224ms
memory: 36356kb

input:

100000 30030 0
1

output:

80481158

result:

ok "80481158"

Test #34:

score: 0
Accepted
time: 214ms
memory: 36672kb

input:

100000 94710 0
1

output:

61977663

result:

ok "61977663"

Test #35:

score: 0
Accepted
time: 73ms
memory: 36412kb

input:

100000 100000 0
1

output:

163629325

result:

ok "163629325"

Subtask #7:

score: 15
Accepted

Dependency #6:

100%
Accepted

Test #36:

score: 15
Accepted
time: 3ms
memory: 18372kb

input:

96 26444 100
1

output:

28274469

result:

ok "28274469"

Test #37:

score: 0
Accepted
time: 3ms
memory: 18508kb

input:

96 1381 98
1

output:

108507497

result:

ok "108507497"

Test #38:

score: 0
Accepted
time: 7ms
memory: 18060kb

input:

100 30030 100
1

output:

96954743

result:

ok "96954743"

Test #39:

score: 0
Accepted
time: 3ms
memory: 18588kb

input:

100 94710 100
1

output:

4473750

result:

ok "4473750"

Test #40:

score: 0
Accepted
time: 6ms
memory: 18612kb

input:

100 100000 100
1

output:

119621887

result:

ok "119621887"

Subtask #8:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #7:

100%
Accepted

Test #41:

score: 15
Accepted
time: 134ms
memory: 36444kb

input:

99996 23632 996
1

output:

25805700

result:

ok "25805700"

Test #42:

score: 0
Accepted
time: 145ms
memory: 36380kb

input:

99998 15516 997
1

output:

55584997

result:

ok "55584997"

Test #43:

score: 0
Accepted
time: 261ms
memory: 36480kb

input:

100000 30030 1000
1

output:

131562265

result:

ok "131562265"

Test #44:

score: 0
Accepted
time: 263ms
memory: 36384kb

input:

100000 94710 1000
1

output:

149443247

result:

ok "149443247"

Test #45:

score: 0
Accepted
time: 101ms
memory: 36448kb

input:

100000 100000 1000
1

output:

111554062

result:

ok "111554062"

Subtask #9:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 3ms
memory: 11408kb

input:

99997 3 997
2
0 1 2
1 2 0
2 0 1
0 0 0
0 1 2
0 2 1

output:


result:

wrong answer Unexpected EOF in the participants output