QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#384268#5356. esperarnKessi17 1ms3908kbC++142.0kb2024-04-09 21:20:372024-04-09 21:20:38

Judging History

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

  • [2024-04-09 21:20:38]
  • 评测
  • 测评结果:17
  • 用时:1ms
  • 内存:3908kb
  • [2024-04-09 21:20:37]
  • 提交

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];
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];
			for(int p = up; p >= 0; p --) {
				for(int q = up; q >= 0; q --) {
					for(int k = 0; k <= b[j]; k ++) {
						for(int u = 0; u <= k; u ++) {
                            if(k == 0 && u == 0) continue;
							if(p >= k && q >= u) {
								DP[p][q] = (DP[p][q] + DP[p - k][q - u]) % 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);
    return 0;
}
/*
g++ -o esperar esperar.cpp -std=c++14 -O2 -fno-ms-extensions -Wconversion -Wshadow
./esperar
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 17
Accepted

Test #1:

score: 17
Accepted
time: 1ms
memory: 3860kb

input:

2
2 3

output:

5

result:

ok single line: '5'

Test #2:

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

input:

4
5 8 8 9

output:

916

result:

ok single line: '916'

Test #3:

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

input:

5
4 8 7 4 10

output:

4939

result:

ok single line: '4939'

Test #4:

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

input:

5
2 7 7 10 10

output:

1125

result:

ok single line: '1125'

Test #5:

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

input:

4
5 5 4 3

output:

84

result:

ok single line: '84'

Test #6:

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

input:

4
5 5 6 4

output:

249

result:

ok single line: '249'

Subtask #2:

score: 0
Time Limit Exceeded

Test #7:

score: 0
Time Limit Exceeded

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:


Subtask #3:

score: 0
Time Limit Exceeded

Test #12:

score: 0
Time Limit Exceeded

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: