結果

問題 No.3431 popcount & sum (Easy)
コンテスト
ユーザー harel
提出日時 2026-01-04 00:02:59
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 2,447 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 6,962 ms
コンパイル使用メモリ 400,284 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-01-11 13:09:44
合計ジャッジ時間 7,467 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) a.begin(),a.end()
#define reps(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, a, n) for (int i = (a); i > (int)(n); i--)
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

ll myceil(ll a, ll b) {return (a+b-1)/b;}

template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using vvv = vv<vc<T>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

#define debug(var) do { cout << #var << " :\n"; view(var); } while(0)
template<typename T>void view(const T& e) {cout << e;}
template<typename T1, typename T2>void view(const pair<T1, T2>& p) {cout << "{" << p.first << ", " << p.second << "}";}
template<typename T>void view(const vc<T>& v) {for (const auto& e : v) {view(e);cout << " ";} cout << endl;}
template<typename T>void view(const vv<T>& vv) {for (const auto& v : vv) {view(v);} cout << endl;}
template<typename T>void view(const set<T>& s) {for (const auto& e : s) {view(e);cout << " ";} cout << endl;}
template<typename T>void view(const multiset<T>& s) {for (const auto& e : s) {view(e);cout << " ";} cout << endl;}
template<typename T>void view(const unordered_set<T>& s) {for (const auto& e : s) {view(e);cout << " ";} cout << endl;}
template<typename T>void view(const unordered_multiset<T>& s) {for (const auto& e : s) {view(e);cout << " ";} cout << endl;}
template<typename T1, typename T2>void view(const map<T1, T2>& mp){for (const auto& e : mp) {view(e);cout << " ";} cout << endl;}


# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")

#include <atcoder/all>
using namespace atcoder;



void solve() {
    ll n;
    cin >> n;

    unsigned long long ans = 0;
    rep(i,n+1) {
        for (int j = i; j <= n; j++) {
            int ip = popcount((unsigned int)i);
            int jp = popcount((unsigned int)j);
            if (ip == jp) {
                ans += i&j;
            }
        }
    }

    cout << ans%998244353 << endl;
    return;
}


int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int t = 1;
    // cin >> t;
    rep(i,t)  solve();

	return 0;
}

0