結果
| 問題 |
No.638 Sum of "not power of 2"
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-04-14 07:31:10 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 460 bytes |
| コンパイル時間 | 196 ms |
| コンパイル使用メモリ | 29,312 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-16 05:18:22 |
| 合計ジャッジ時間 | 857 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
ソースコード
// yukicoder: No.638 Sum of "not power of 2"
// 2019.4.14 bal4u
#include <stdio.h>
char f[17] = { 1,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1 };
int check(long long n)
{
while ((n & 1) == 0) n >>= 1;
return n > 1;
}
int main()
{
int i, ans;
long long N;
scanf("%lld", &N);
ans = -1;
for (i = 3; i < 17 && i < N; i++) {
if (f[i]) continue;
if (check(N - i)) { ans = i; break; }
}
if (ans < 0) puts("-1");
else printf("%d %lld\n", i, N-i);
return 0;
}
bal4u