結果
| 問題 |
No.1452 XOR×OR
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-03-31 15:31:30 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 670 bytes |
| コンパイル時間 | 600 ms |
| コンパイル使用メモリ | 65,908 KB |
| 最終ジャッジ日時 | 2025-01-20 01:54:00 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
#line 1 "main.cpp"
#include <iostream>
using namespace std;
using lint = long long;
void solve() {
lint n;
cin >> n;
lint ans = 0;
for (lint x = 1; x * x <= n; ++x) {
if (n % x != 0) continue;
auto y = n / x; // A|B
auto z = y - x; // A&B
// z in y が必要
if ((y & z) == z) {
// y\z は自由に選べる
ans += 1LL << __builtin_popcount(y - z);
}
}
// A<=B なので、ダブりを省く
// A=B で A^B=0 なのでOK
ans /= 2;
cout << ans << "\n";
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
solve();
return 0;
}