結果

問題 No.1452 XOR×OR
ユーザー ぷら
提出日時 2021-03-31 14:37:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 1,575 ms
コンパイル使用メモリ 166,848 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 15:39:28
合計ジャッジ時間 2,463 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

long long intpow(long long a, long long b){
    long long ans = 1;
    while(b) {
        if(b & 1) {
            ans *= a;
        }
        a *= a;
        b /= 2;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i*i <= N; i++) {
        if(N%i == 0) {
            int x = i;
            int y = N/i;
            if((x | y) == x) {
                ans += intpow(2,__builtin_popcountll(y)-1);
            }
            if((x | y) == y && x != y) {
                ans += intpow(2,__builtin_popcountll(x)-1);
            }
        }
    }
    cout << ans << endl;
}
0