Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
30840 | 沈仲恩 | 【S】T1 | C++ | 解答错误 | 0 | 3000 MS | 7080 KB | 1770 | 2024-07-30 20:59:48 |
#include <bits/stdc++.h> #define int long long #define mod 998244353 #define fir first #define sec second using namespace std; int t, n, a; map <int, priority_queue <int>> aa; queue <int> q; inline int ksm(int x, int y) { int res = 1; while (y) { if (y & 1) res = res * x % mod; x = x * x % mod, y >>= 1; } return res; } signed main() { //int sttt = clock(); //freopen("inequality.in", "r", stdin); //freopen("inequality.out", "w", stdout); // for (int i = 2; i <= 1000000; i++) // inv[i] = (mod - mod / i) % mod * inv[i - 1] % mod; // inv[i] = ksm(i, mod - 2); // printf("%lld %lld\n", 2 * inv[2] % mod, 6 * inv[3] % mod); scanf("%lld", &t); while (t--) { scanf("%lld", &n); int ans = 0; for (int i = 1; i <= n; i++) { scanf("%lld", &a); for (int j = 2; j * j <= a; j++) { if (a % j == 0) { int cnt = 0; while (a % j == 0) cnt++, a /= j; aa[j].push(cnt); } } } int cur; for (int i = 1; i <= n; i++) { cur = 1; for (pair <int, priority_queue <int>> p : aa) { if (!(p.sec).empty()) { cur = cur * ksm(p.fir, (p.sec).top()) % mod; (p.sec).pop(); } } ans = (ans + cur) % mod; } printf("%lld\n", ans); } // printf("Run time:%lldms", (clock() - sttt) * 1000 / CLOCKS_PER_SEC); return 0; }