結果

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

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
using ll = long long;
#define overload4(a, b, c, d, name, ...) name
#define rep1(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
void solve();
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) solve();
    return 0;
}
ll dy[4] = {-1, 0, 1, 0}, dx[4] = {0, 1, 0, -1};
void solve() {
    ll n;
    cin >> n;
    ll res = 0;
    rep(i, n + 1) rep(j, i, n + 1) {
        ll popi = __builtin_popcount(i), popj = __builtin_popcount(j);
        if (popi == popj) res += i & j;
    }
    cout << res << endl;
}
0