QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#110560#5356. esperarzhoukangyang0 5ms3540kbC++171.4kb2023-06-02 20:05:392023-06-02 20:05:43

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-02 20:05:43]
  • 评测
  • 测评结果:0
  • 用时:5ms
  • 内存:3540kb
  • [2023-06-02 20:05:39]
  • 提交

answer

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i)
#define R(i, j, k) for(int i = (j); i >= (k); --i)
#define ll long long
#define sz(a) ((int) (a).size())
#define vi vector < int > 
#define me(a, x) memset(a, x, sizeof(a))
#define ull unsigned long long
#define ld __float128
using namespace std;
const int N = 5007, mod = 998244353, inv2 = (mod + 1) / 2;

int n, a[N];
int A[N], B[N], tot;

map < int, vi > MP;
int pool[N * 4], *dp = pool + N, *ndp = pool + N * 3;
int main() {
//	freopen("tree.in", "r", stdin);
//	freopen("tree.out", "w", stdout);
	ios :: sync_with_stdio(false); 
	cin.tie(0); cout.tie(0);
	cin >> n;
	L(i, 1, n) {
		cin >> a[i];
	}
	L(i, 1, n) {
		ll x = a[i];
		L(p, 2, sqrt(x)) {
			int cnt = 0;
			while(x % p == 0) x /= p, ++cnt;
			++tot, A[tot] = x, B[tot] = cnt;
		}
		if(x > 1) ++tot, A[tot] = x, B[tot] = 1;
	}
	
	int prd = 1;
	L(i, 1, tot) {
		prd = (ll) prd * ((B[i] + 1) * (B[i] + 2) / 2) % mod;
	}
	L(i, 1, tot) {
		MP[A[i]].emplace_back(B[i]);
	}
	
	int ans = 1;
	for(auto u : MP) {
		int sum = 0;
		dp[0] = 1;
		for(auto k : u.second) {
			L(i, -sum, sum) {
				L(x, 0, k) {
					L(y, x, k) {
						(ndp[i + x * 2 - y] += dp[i]) %= mod;
					}
				}
			}
			L(i, -sum, sum) dp[i] = 0;
			sum += k;
			swap(dp, ndp);
		}
		ans = (ll) ans * dp[0] % mod;
		L(i, -sum, sum)
			dp[i] = 0;
	} 
	cout << (ll) (prd + ans) * inv2 % mod << '\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: -17
Wrong Answer
time: 0ms
memory: 3448kb

input:

4
5 8 8 9

output:

942

result:

wrong answer 1st lines differ - expected: '916', found: '942'

Subtask #2:

score: 0
Wrong Answer

Test #7:

score: 0
Wrong Answer
time: 2ms
memory: 3540kb

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:

790992015

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 5ms
memory: 3416kb

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:

790992015

result:

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