QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384359#5356. esperarnKessi17 153ms17144kbC++142.5kb2024-04-09 22:18:102024-04-09 22:18:10

Judging History

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

  • [2024-04-09 22:18:10]
  • 评测
  • 测评结果:17
  • 用时:153ms
  • 内存:17144kb
  • [2024-04-09 22:18:10]
  • 提交

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], 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() {
	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 <= up; 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][q]) % Mod;
                        if(q - k - 1 >= 0) DP[p][q] = (DP[p][q] - pre[p - k][q - k - 1]) % Mod;
                        // printf("?%d %d %d %d %d?\n", i.first, j, p, q, DP[p][q]);
					}
				}
			}
		}
		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);
    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: 5824kb

input:

2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5828kb

input:

4
5 8 8 9

output:

916

result:

ok single line: '916'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5836kb

input:

5
4 8 7 4 10

output:

4939

result:

ok single line: '4939'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5876kb

input:

5
2 7 7 10 10

output:

1125

result:

ok single line: '1125'

Test #5:

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

input:

4
5 5 4 3

output:

84

result:

ok single line: '84'

Test #6:

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

input:

4
5 5 6 4

output:

249

result:

ok single line: '249'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 153ms
memory: 17136kb

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:

-521827665

result:

wrong answer 1st lines differ - expected: '476416688', found: '-521827665'

Subtask #3:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 152ms
memory: 17144kb

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:

-521827665

result:

wrong answer 1st lines differ - expected: '476416688', found: '-521827665'