結果
| 問題 |
No.638 Sum of "not power of 2"
|
| コンテスト | |
| ユーザー |
🍮かんプリン
|
| 提出日時 | 2019-03-18 10:10:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 972 bytes |
| コンパイル時間 | 648 ms |
| コンパイル使用メモリ | 64,352 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 00:28:49 |
| 合計ジャッジ時間 | 1,213 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
ソースコード
#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++)
{
ll 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;
}
🍮かんプリン