QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384365#5356. esperarnKessi0 47ms26904kbC++142.5kb2024-04-09 22:20:332024-04-09 22:20:34

Judging History

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

  • [2024-04-09 22:20:34]
  • 评测
  • 测评结果:0
  • 用时:47ms
  • 内存:26904kb
  • [2024-04-09 22:20:33]
  • 提交

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() {
	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][q];
                        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: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5900kb

input:

2
2 3

output:

499122179

result:

wrong answer 1st lines differ - expected: '5', found: '499122179'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 47ms
memory: 26904kb

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:

272585448

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 46ms
memory: 26564kb

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:

272585448

result:

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