結果
問題 |
No.638 Sum of "not power of 2"
|
ユーザー |
![]() |
提出日時 | 2019-03-18 10:08:22 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 973 bytes |
コンパイル時間 | 505 ms |
コンパイル使用メモリ | 64,248 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-18 00:25:47 |
合計ジャッジ時間 | 1,299 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 1 |
ソースコード
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <math.h> using ll = long long; using namespace std; const int MOD = 1e9+7; int main() { ll n; cin >> n; if (n != 6 && n <= 7) { cout << -1 << endl; } else if (n == 6) { cout << "3 3" << endl; } else { bool two3, two5, two6; two3 = two5 = two6 = false; for(int i = 0; i < 64; i++) { int a = (1LL << i); if ((n - 3) == a) two3 = true; if ((n - 5) == a) two5 = true; if ((n - 6) == a) two6 = true; if (two3 && two5 && two6) break; } if (!two3) { cout << "3 " << n - 3 << endl; } else if (!two5) { cout << "5 " << n - 5 << endl; } else if (!two6) { cout << "6 " << n - 6 << endl; } else { cout << -1 << endl; } } return 0; }