QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#384271#5356. esperarnKessi17 534ms7196kbC++142.1kb2024-04-09 21:21:592024-04-09 21:22:00

Judging History

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

  • [2024-04-09 21:22:00]
  • 评测
  • 测评结果:17
  • 用时:534ms
  • 内存:7196kb
  • [2024-04-09 21:21:59]
  • 提交

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];
            if(b[j] == 0) continue;
			for(int p = up; p >= 0; p --) {
				for(int q = p; 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
*/

詳細信息

Subtask #1:

score: 17
Accepted

Test #1:

score: 17
Accepted
time: 0ms
memory: 3912kb

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: 0ms
memory: 3872kb

input:

5
4 8 7 4 10

output:

4939

result:

ok single line: '4939'

Test #4:

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

input:

5
2 7 7 10 10

output:

1125

result:

ok single line: '1125'

Test #5:

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

input:

4
5 5 4 3

output:

84

result:

ok single line: '84'

Test #6:

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

input:

4
5 5 6 4

output:

249

result:

ok single line: '249'

Subtask #2:

score: 0
Time Limit Exceeded

Test #7:

score: 32
Accepted
time: 522ms
memory: 7120kb

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: -32
Time Limit Exceeded

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:


result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #12:

score: 51
Accepted
time: 534ms
memory: 7196kb

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: -51
Time Limit Exceeded

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:


result: