結果
問題 | No.638 Sum of "not power of 2" |
ユーザー |
![]() |
提出日時 | 2018-01-29 12:43:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 392 bytes |
コンパイル時間 | 513 ms |
コンパイル使用メモリ | 54,108 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 02:55:01 |
合計ジャッジ時間 | 1,068 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <iostream> #define int long long using namespace std; int n; int bitCnt(int a) { int ret = 0; for (int i = 60; i >= 0; i--) { if ((a >> i) & 1) ret++; } return ret; } signed main() { cin >> n; for (int a = 1; a < n; a++) { int b = n - a; if (bitCnt(a) != 1 && bitCnt(b) != 1) { cout << a << " " << b << endl; return 0; } } cout << -1 << endl; return 0; }