結果
| 問題 |
No.638 Sum of "not power of 2"
|
| コンテスト | |
| ユーザー |
incuiio
|
| 提出日時 | 2023-05-18 17:02:12 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,134 bytes |
| コンパイル時間 | 1,270 ms |
| コンパイル使用メモリ | 127,736 KB |
| 最終ジャッジ日時 | 2025-02-13 01:13:39 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
ソースコード
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>
#include <cassert>
#include <regex>
using std::cout;
using std::cin;
using std::string;
using std::vector;
int main()
{
vector<long long> powers;
long long i = 1;
while (i < 1e18)
{
powers.push_back(i);
i *= 2;
}
long long n;
cin >> n;
bool ans = false;
long long x, y;
for (long long a = 1; a < n; a++)
{
long long b = n - a;
bool is_power = false;
for (int i = 0; i < powers.size(); i++)
{
if (a == powers[i] || b == powers[i])
{
is_power = true;
break;
}
}
if (!is_power)
{
ans = true;
x = a;
y = b;
break;
}
}
if (ans)
{
cout << x << ' ' << y;
}
else
{
cout << -1;
}
}
incuiio