結果

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

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using mint = atcoder::modint998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    mint ans;
    for(int a = 0; a <= n; a++){
        int acnt = __builtin_popcount(a);
        for(int b = a; b <= n; b++){
            int bcnt = __builtin_popcount(b);
            if(acnt == bcnt) ans += mint::raw(a & b);
        }
    }
    cout << ans.val() << '\n';
}
0