// 2024 (ICPC) Jiangxi Provincial Contest -- Official Contest // Totoroの旅 #include<bits/stdc++.h> usingnamespace std; using ll = longlong; constint mod = 998244353; constint N = 1e6 + 100; const ll INF = 1e18; ll ksm(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) { ans = ans * a % mod; } a = a * a % mod; b >>= 1; } return ans % mod; } int p[N]; int sum; int vis[N]; voidprime() { for (int i = 2; i <= N; i++) { if (!vis[i]) { p[++sum] = i; } for (int j = 1; p[j] * i <= N; j++) { vis[p[j] * i] = 1; if (i % p[j] == 0) { break; } } } vis[1] = 1; } voidTotoro() { int n; cin >> n; vector<int> a(n + 1); map<int, vector<int>> mp; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 1; i <= n; i++) { int x = a[i]; for (int j = 1; j <= sum; j++) { if (p[j] * p[j] > x) { break; } int cnt = 0; while (x % p[j] == 0) { x /= p[j]; cnt++; } if (cnt != 0) { mp[p[j]].push_back(cnt); } } if (x > 1) { mp[x].push_back(1); } } int len = 0; for (auto &x : mp) { auto &vec = x.second; len = max(len, (int)vec.size()); sort(vec.begin(), vec.end()); } int k = 1; int ans = 0; for (int i = 0; i < len; i++) { int t = 1; for (auto it = mp.begin(); it != mp.end();) { auto &vec = it->second; int siz = vec.size(); if (siz - k >= 0) { t = (t * ksm(it->first, vec[siz - k])) % mod; if (siz - k == 0) { mp.erase(it++); } else { ++it; } } } k++; ans = (ans + t) % mod; } ans = (ans + (n - len)) % mod; cout << ans << '\n'; } intmain() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t; prime(); while (t--) { Totoro(); } return0; }
// 2024 (ICPC) Jiangxi Provincial Contest -- Official Contest // Totoroの旅 #include<bits/stdc++.h> usingnamespace std; using ll = longlong; constint mod = 998244353; constint N=1e3+100; int a[N][N]; ll ksm(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) { ans = ans * a % mod; } a = a * a % mod; b >>= 1; } return ans % mod; } voidTotoro() { int n, m; cin >> n >> m; int p, q; cin >> p >> q; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1]; } } ll ans = 0; for (int i = 1; i <= p; i++) { for (int j = 1; j <= q; j++) { int x = n - p + i; int y = m - q + j; ans += abs(a[x][y] - a[i - 1][y] - a[x][j - 1] + a[i - 1][j - 1]); } } cout << ans << '\n'; } intmain() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t--) { Totoro(); } return0; }
// 2024 (ICPC) Jiangxi Provincial Contest -- Official Contest // Totoroの旅 #include<bits/stdc++.h> usingnamespace std; using ll = longlong; constint mod = 998244353; ll ksm(ll a, ll b) { ll ans = 1; while (b) { if (b & 1) { ans = ans * a % mod; } a = a * a % mod; b >>= 1; } return ans % mod; } voidTotoro() { int n; cin >> n; cout << ksm(2, n - 1) << '\n'; } intmain() { int t = 1; // cin >> t; while (t--) { Totoro(); } return0; }
L
题意:一个 n 个点 m 条边的无向图,每个节点上有 \(a_i\) 个人。n 个节点中有 k 个
节点为出口,每个出口有一个开放时间 [\(l_i\) ,$ r_i$ ]。求第 1 ∼ T 时刻所有人到
最近的开放出口的路径长度之和。