結果
| 問題 | No.3662 yuu Hates Sigma Problem |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-30 16:06:09 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,003 bytes |
| 記録 | |
| コンパイル時間 | 4,375 ms |
| コンパイル使用メモリ | 375,268 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-08-30 16:06:22 |
| 合計ジャッジ時間 | 7,613 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| subtask1. | 20 % | AC * 19 |
| subtask2. | 30 % | AC * 13 |
| subtask3. | 50 % | AC * 31 WA * 18 |
| 合計 | 2.5 * 50% = 125 点 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
//using mint = modint1000000007;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
template<typename T_>bool chmax(T_& a, const T_& b) { if (a < b) { a = b;return true; } else { return false; } }
template<typename T_>bool chmin(T_& a, const T_& b) { if (a > b) { a = b;return true; } else { return false; } }
#ifdef LOCAL
template<class T, class U> ostream& operator<<(ostream& o, const pair<T, U>& p) { return o << "(" << p.first << ", " << p.second << ")"; }
template<class... T> ostream& operator<<(ostream& o, const tuple<T...>& t) { o << "("; apply([&o](auto&&... a) { int c = 0; (((o << (c++ ? ", " : "") << a)), ...); }, t); return o << ")"; }
template<class V> auto operator<<(ostream& o, const V& v) -> std::enable_if_t<!std::is_same_v<V, std::string> && !std::is_same_v<V, std::string_view>, decltype(v.begin(), o)> { o << "{"; int c = 0; for (auto& x : v) o << (c++ ? ", " : "") << x; return o << "}"; }
#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"]: ",([](auto&&... a){((cerr<<a<<' '),...);})(__VA_ARGS__),cerr<<'\n'
#else
#define dbg(...) void(0)
#endif
const int di[] = { -1,0,1,0 };
const int dj[] = { 0,-1,0,1 };
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
void solve() {
int n;cin >> n;
if (n <= 3000) {
vector<int> a(n, 0);
mint ans = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
// mint sum = 0;
// ll pw = 1;
// while (pw <= n) {
// pw *= 2;
// ll cnt = (n + 1) / pw;
// sum += cnt * (n - cnt) * pw / 2;
// dbg(sum.val());
// }
// ans += sum * a[i];
mint sum = 0;
for (int j = 0; j < n; j++) {
sum += i ^ j;
}
ans += a[i] * sum;
}
cout << ans.val() << "\n";
return;
}
vector<int> a(n, 0);
mint ans = 0;
vector<int> xx(32, 0);
for (int i = 0; i < n; i++) {
int lim = 1;
for (int j = 0; j < 32; j++) {
lim *= 2;
if (lim > n)break;
if ((i >> j) & 1) {
xx[j]++;
}
dbg(j, xx[j]);
}
}
for (int i = 0; i < n; i++) {
cin >> a[i];
mint sum = 0;
int lim = 1;
mint pw = 1;
for (int j = 0; j < 32; j++) {
lim *= 2;
if (lim > n)break;
if ((i >> j) & 1) {
sum += (n - xx[j]) * pw;
}
else {
sum += xx[j] * pw;
}
pw *= 2;
dbg(i, xx[j], sum.val());
}
ans += sum * a[i];
}
cout << ans.val() << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}