結果
| 問題 | No.1452 XOR×OR | 
| コンテスト | |
| ユーザー |  🍮かんプリン | 
| 提出日時 | 2021-04-01 02:05:54 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 739 bytes | 
| コンパイル時間 | 1,512 ms | 
| コンパイル使用メモリ | 166,092 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-02 15:42:15 | 
| 合計ジャッジ時間 | 2,545 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 | 
ソースコード
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2021.04.01 02:05:49
**/
#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;
int bitpopcount(ll n) {
    int res = 0;
    while (n) {
        if (n & 1) res++;
        n >>= 1;
    }
    return res;
}
template<typename T, typename U>
T _pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}
int main() {
    int n;cin >> n;
    ll ans = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i != 0) continue;
        if ((i & (n/i)) != i) continue;
        
        ans += _pow(2,bitpopcount(i)-1);
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        