結果
問題 | No.638 Sum of "not power of 2" |
ユーザー |
|
提出日時 | 2024-12-11 17:14:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 491 bytes |
コンパイル時間 | 629 ms |
コンパイル使用メモリ | 66,316 KB |
最終ジャッジ日時 | 2025-02-26 12:01:01 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <iostream> #include <cstdint> using namespace std; constexpr uint16_t pop_count(uint64_t a) noexcept { uint16_t ans = UINT16_C(0); for (; a != UINT64_C(0); a >>= UINT64_C(1)) if (a & UINT64_C(1)) ++ans; return ans; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint64_t N, i; cin >> N; for (i = 1; i != N; ++i) if (pop_count(i) != 1 && pop_count(N - i) != 1) { cout << i << ' ' << N - i << '\n'; return 0; } cout << "-1\n"; return 0; }