結果
問題 | No.638 Sum of "not power of 2" |
ユーザー |
![]() |
提出日時 | 2017-08-13 14:02:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 419 bytes |
コンパイル時間 | 674 ms |
コンパイル使用メモリ | 63,744 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 02:14:09 |
合計ジャッジ時間 | 1,931 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#include <iostream>using namespace std;bool solve(long long x) {for (long long i = 1; i <= x; i *= 2) {if (i == x) return true;}return false;}long long n;int main() {cin >> n;int p = -1;for (int i = 1; i < n && i <= 121; i++) {if (!solve(i) && !solve(n - i)) {p = i;break;}}if (p == -1) cout << -1 << endl;else cout << p << ' ' << n - p << endl;return 0;}