QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#235170#5356. esperarmemset00 3ms10052kbC++202.7kb2023-11-02 15:31:522023-11-02 15:31:52

Judging History

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

  • [2023-11-02 15:31:52]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:10052kb
  • [2023-11-02 15:31:52]
  • 提交

answer

// =================================
//   author: memset0
//   date: 2019.07.07 11:14:03
//   website: https://memset0.cn/
// =================================
#include <bits/stdc++.h>
#define ll long long
#define debug(...) ((void)0)
#ifndef debug
#define debug(...) fprintf(stderr,__VA_ARGS__)
#endif
namespace ringo {
template <class T> inline void read(T &x) {
	x = 0; char c = getchar(); bool f = 0;
	while (!isdigit(c)) f ^= c == '-', c = getchar();
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
	if (f) x = -x;
}
template <class T> inline void print(T x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar('0' + x % 10);
}
template <class T> inline void print(T x, char c) { print(x), putchar(c); }
template <class T> inline void print(T a, int l, int r, std::string s = "") {
	if (s != "") std::cout << s << ": ";
	for (int i = l; i <= r; i++) print(a[i], " \n"[i == r]);
}

const int N = 110, M = 1e5 + 10, mod = 998244353;
int n, min, max, ans = 1, sum = 1, pcnt;
int a[N], b[N][M], c[M][N], pri[M], vis[M], f[M], g[M];

inline int dec(int a, int b) { a -= b; return a < 0 ? a + mod : a; }
inline int inc(int a, int b) { a += b; return a >= mod ? a - mod : a; }
inline int mul(int a, int b) { return (ll)a * b - (ll)a * b / mod * mod; }

void init_pri(int limit) {
	for (int i = 2; i < limit; i++) {
		if (!vis[i]) pri[++pcnt] = i;
		for (int j = 1; j <= pcnt && i * pri[j] < limit; j++)
			{ vis[i * pri[j]] = 1; if (i % pri[j] == 0) break; }
	}
}

void split(int x, int *cnt) {
	static std::map<int, int> map;
	for (int i = 1; i <= pcnt; i++) while (x % pri[i] == 0) ++cnt[i], x /= pri[i];
	if (x != 1) ++cnt[map.find(x) == map.end() ? (pri[++pcnt] = x, map[x] = pcnt) : map[x]];
}

int solve(int *cnt) {
	for (register int i = min; i <= max; i++) f[i] = 0;
	min = max = 0, f[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= cnt[i]; j++)
			for (int k = 0; k <= j; k++)
				for (int i = min; i <= max; i++)
					g[i + (k << 1) - j] = inc(g[i + (k << 1) - j], f[i]);
		min -= cnt[i], max += cnt[i];
		for (register int i = min; i <= max; i++) f[i] = g[i], g[i] = 0;
	}
	return f[0];
}

void main() {
	read(n), init_pri(1e5);
	for (int i = 1; i <= n; i++) read(a[i]), split(a[i], b[i]);
	for (int i = 1; i <= n; i++) for (int j = 1; j <= pcnt; j++) c[j][i] = b[i][j];
	for (int i = 1; i <= pcnt; i++) ans = mul(ans, solve(c[i]));
	for (int i = 1; i <= pcnt; i++) for (int j = 1; j <= n; j++) sum = mul(sum, mul((mod + 1) >> 1, mul(c[i][j] + 2, c[i][j] + 1)));
	print(mul(inc(ans, sum), (mod + 1) >> 1), '\n');
}

} signed main() {
#ifdef MEMSET0_LOCAL_ENVIRONMENT
	freopen("1.in", "r", stdin);
#endif
	return ringo::main(), 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 17
Accepted
time: 2ms
memory: 10052kb

input:

2
2 3

output:

5

result:

ok single line: '5'

Test #2:

score: -17
Wrong Answer
time: 3ms
memory: 8980kb

input:

4
5 8 8 9

output:

33667

result:

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

Subtask #2:

score: 0
Runtime Error

Test #7:

score: 0
Runtime Error

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:


result:


Subtask #3:

score: 0
Runtime Error

Test #12:

score: 0
Runtime Error

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:


result: