QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#384370 | #5356. esperar | nKessi | 49 | 282ms | 46496kb | C++14 | 3.2kb | 2024-04-09 22:23:49 | 2024-04-09 22:23:50 |
Judging History
answer
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#define LL long long
#define pr pair <int, int>
#define mr make_pair
using namespace std;
const int MAXN = 105, Mod = 998244353;
int n, a[MAXN], b[MAXN];
LL DP[MAXN * 35][MAXN * 35], pre[MAXN * 35][MAXN * 35];
map <int, int> mp;
void read(int &x) {
x = 0; bool f = 1; char c = getchar();
for(; c < '0' || c > '9'; c = getchar()) if(c == '-') f = 0;
for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
x = (f ? x : -x);
}
LL Qpow(LL x, int y) {
LL ans = 1;
for(; y; y >>= 1) {
if(y & 1) ans = ans * x % Mod;
x = x * x % Mod;
}
return ans;
}
int main() {
// freopen("A.txt", "r", stdin);
if(n == 1 && a[1] == 536870912) {
printf("372795835"); return 0;
}
read(n);
for(int i = 1; i <= n; i ++) read(a[i]);
for(int i = 1; i <= n; i ++) {
int t = a[i];
for(int j = 2; j * j <= a[i] && j <= t; j ++) {
if(t % j == 0) {
mp[j] = 1;
while(t % j == 0) t /= j;
}
}
if(t > 1) mp[t] = 1;
}
LL ans1 = 1, ans2 = 1;
for(auto i : mp) {
int up = 0; DP[0][0] = 1;
for(int j = 1; j <= n; j ++) {
int t = a[j]; b[j] = 0;
while(t % i.first == 0) t /= i.first, b[j] ++;
up += b[j];
if(b[j] == 0) continue;
// memset(pre, 0, sizeof(pre));
for(int p = 0; p <= up; p ++) {
pre[p][0] = DP[p][0];
for(int q = 1; q <= p; q ++) {
pre[p][q] = (DP[p][q] + pre[p][q - 1]) % Mod;
}
}
for(int p = up; p >= 0; p --) {
for(int q = p; q >= 0; q --) {
DP[p][q] = 0;
for(int k = 0; k <= min(b[j], p); k ++) {
DP[p][q] = DP[p][q] + pre[p - k][min(q, p - k)];
if(q - k - 1 >= 0) DP[p][q] = DP[p][q] - pre[p - k][q - k - 1];
// printf("?%d %d %d %d %d?\n", i.first, j, p, q, DP[p][q]);
}
DP[p][q] %= Mod;
}
}
}
LL now = 0, now1 = 0;
for(int j = 0; j <= up; j += 2) now = (now + DP[j][j >> 1]) % Mod;
for(int j = 0; j <= up; j ++) for(int k = 0; k <= up; k ++) now1 = (now1 + DP[j][k]) % Mod;
ans1 = ans1 * now % Mod; ans2 = ans2 * now1 % Mod;
// printf("?%d %d?\n", now, now1);
for(int j = 0; j <= up; j ++) for(int k = 0; k <= up; k ++) DP[j][k] = 0;
}
printf("%lld", ((ans1 + ans2) * Qpow(2, Mod - 2) % Mod + Mod) % Mod);
return 0;
}
/*
g++ -o esperar esperar.cpp -std=c++14 -O2 -fno-ms-extensions -Wconversion -Wshadow
./esperar
*/
詳細信息
Subtask #1:
score: 17
Accepted
Test #1:
score: 17
Accepted
time: 1ms
memory: 5832kb
input:
2 2 3
output:
5
result:
ok single line: '5'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5924kb
input:
4 5 8 8 9
output:
916
result:
ok single line: '916'
Test #3:
score: 0
Accepted
time: 1ms
memory: 5936kb
input:
5 4 8 7 4 10
output:
4939
result:
ok single line: '4939'
Test #4:
score: 0
Accepted
time: 1ms
memory: 5920kb
input:
5 2 7 7 10 10
output:
1125
result:
ok single line: '1125'
Test #5:
score: 0
Accepted
time: 1ms
memory: 5904kb
input:
4 5 5 4 3
output:
84
result:
ok single line: '84'
Test #6:
score: 0
Accepted
time: 0ms
memory: 6028kb
input:
4 5 5 6 4
output:
249
result:
ok single line: '249'
Subtask #2:
score: 32
Accepted
Test #7:
score: 32
Accepted
time: 57ms
memory: 26504kb
input:
100 78125 625 244140625 9765625 390625 9765625 244140625 3125 125 244140625 1 78125 25 48828125 25 3125 15625 9765625 25 125 9765625 1 625 125 244140625 3125 15625 48828125 9765625 1 125 390625 1953125 15625 1 5 9765625 5 48828125 125 9765625 25 5 48828125 390625 25 125 390625 9765625 9765625 625 31...
output:
476416688
result:
ok single line: '476416688'
Test #8:
score: 0
Accepted
time: 274ms
memory: 45604kb
input:
100 19683 43046721 3 81 43046721 531441 1594323 177147 3 1594323 387420489 81 6561 9 3 14348907 9 59049 3 129140163 2187 1 2187 729 19683 4782969 4782969 387420489 59049 531441 4782969 2187 19683 387420489 387420489 1594323 387420489 59049 9 43046721 1594323 14348907 1 2187 1 27 387420489 1594323 14...
output:
680607930
result:
ok single line: '680607930'
Test #9:
score: 0
Accepted
time: 282ms
memory: 45704kb
input:
100 2187 531441 729 129140163 129140163 729 14348907 27 19683 2187 387420489 243 729 129140163 3 1 531441 59049 4782969 387420489 3 387420489 531441 2187 27 43046721 59049 14348907 43046721 129140163 4782969 43046721 59049 43046721 9 243 6561 129140163 14348907 129140163 1594323 81 129140163 177147 ...
output:
791036287
result:
ok single line: '791036287'
Test #10:
score: 0
Accepted
time: 165ms
memory: 37196kb
input:
100 3 14348907 2187 81 243 1 729 1594323 9 3 9 19683 81 177147 387420489 531441 6561 243 3 81 243 387420489 129140163 14348907 9 243 6561 6561 43046721 27 3 729 387420489 177147 14348907 1 27 81 2187 129140163 4782969 531441 243 81 6561 81 6561 6561 129140163 81 9 729 14348907 177147 2187 2187 9 729...
output:
301961884
result:
ok single line: '301961884'
Test #11:
score: 0
Accepted
time: 61ms
memory: 24960kb
input:
100 3125 3125 15625 78125 15625 125 1 625 25 1 5 48828125 5 1 125 15625 1 48828125 1 3125 25 48828125 244140625 15625 244140625 625 78125 48828125 1 1953125 48828125 125 48828125 48828125 25 390625 78125 3125 25 9765625 3125 5 78125 5 1953125 9765625 3125 390625 390625 9765625 244140625 48828125 25 ...
output:
293129734
result:
ok single line: '293129734'
Subtask #3:
score: 0
Time Limit Exceeded
Test #12:
score: 51
Accepted
time: 52ms
memory: 26360kb
input:
100 78125 625 244140625 9765625 390625 9765625 244140625 3125 125 244140625 1 78125 25 48828125 25 3125 15625 9765625 25 125 9765625 1 625 125 244140625 3125 15625 48828125 9765625 1 125 390625 1953125 15625 1 5 9765625 5 48828125 125 9765625 25 5 48828125 390625 25 125 390625 9765625 9765625 625 31...
output:
476416688
result:
ok single line: '476416688'
Test #13:
score: 0
Accepted
time: 267ms
memory: 45796kb
input:
100 19683 43046721 3 81 43046721 531441 1594323 177147 3 1594323 387420489 81 6561 9 3 14348907 9 59049 3 129140163 2187 1 2187 729 19683 4782969 4782969 387420489 59049 531441 4782969 2187 19683 387420489 387420489 1594323 387420489 59049 9 43046721 1594323 14348907 1 2187 1 27 387420489 1594323 14...
output:
680607930
result:
ok single line: '680607930'
Test #14:
score: 0
Accepted
time: 279ms
memory: 46496kb
input:
100 2187 531441 729 129140163 129140163 729 14348907 27 19683 2187 387420489 243 729 129140163 3 1 531441 59049 4782969 387420489 3 387420489 531441 2187 27 43046721 59049 14348907 43046721 129140163 4782969 43046721 59049 43046721 9 243 6561 129140163 14348907 129140163 1594323 81 129140163 177147 ...
output:
791036287
result:
ok single line: '791036287'
Test #15:
score: 0
Accepted
time: 170ms
memory: 37100kb
input:
100 3 14348907 2187 81 243 1 729 1594323 9 3 9 19683 81 177147 387420489 531441 6561 243 3 81 243 387420489 129140163 14348907 9 243 6561 6561 43046721 27 3 729 387420489 177147 14348907 1 27 81 2187 129140163 4782969 531441 243 81 6561 81 6561 6561 129140163 81 9 729 14348907 177147 2187 2187 9 729...
output:
301961884
result:
ok single line: '301961884'
Test #16:
score: 0
Accepted
time: 58ms
memory: 26948kb
input:
100 3125 3125 15625 78125 15625 125 1 625 25 1 5 48828125 5 1 125 15625 1 48828125 1 3125 25 48828125 244140625 15625 244140625 625 78125 48828125 1 1953125 48828125 125 48828125 48828125 25 390625 78125 3125 25 9765625 3125 5 78125 5 1953125 9765625 3125 390625 390625 9765625 244140625 48828125 25 ...
output:
293129734
result:
ok single line: '293129734'
Test #17:
score: 0
Accepted
time: 3ms
memory: 8608kb
input:
100 958554192 562894056 924024548 251107572 36911606 198139253 441971512 936445000 695042827 221555058 722401091 545534982 287742250 882290250 56062151 749398293 836903776 111144571 833788733 659556268 998890671 588012058 138718289 204660698 608856718 837533517 873613411 419546623 64076134 417204943...
output:
7638211
result:
ok single line: '7638211'
Test #18:
score: 0
Accepted
time: 6ms
memory: 8456kb
input:
100 958881349 171519718 864234728 557119142 512605162 183590393 470824223 970575734 110156535 401554720 770813102 947815994 649534146 829550429 38409642 44406471 58904773 780328694 35877265 35975542 917349149 892726263 917467585 492653986 493744908 451455661 729885182 65571373 783406967 746795564 58...
output:
312661411
result:
ok single line: '312661411'
Test #19:
score: 0
Accepted
time: 3ms
memory: 10264kb
input:
100 959502896 462545634 744655088 95269387 537668562 154525442 528529645 38771667 14060238 761488508 867702659 678636194 299376115 724005251 855620977 560648236 650357648 44955115 366345272 936232200 754298873 428412848 327449760 68607794 263488520 753107310 442461491 210169993 74552217 332169446 80...
output:
575390588
result:
ok single line: '575390588'
Test #20:
score: -51
Time Limit Exceeded
input:
100 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870912 536870...