結果
問題 | No.638 Sum of "not power of 2" |
ユーザー |
![]() |
提出日時 | 2018-01-27 11:47:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 377 bytes |
コンパイル時間 | 1,657 ms |
コンパイル使用メモリ | 166,144 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-30 02:52:11 |
合計ジャッジ時間 | 2,377 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%lld", &n); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; map<ll, int> mp; int main(){ ll t = 1, n, ans = -1; mp[t] = 1; while(t*2 < 1e18){ t *= 2; mp[t] = 1; } scanf("%lld", &n); for(int i = 1;i < n;i++){ if(mp[i] == 0 && mp[n-i] == 0){ ans = i; break; } } if(ans == -1)printf("-1\n"); else printf("%lld %lld\n", ans, n-ans); return 0; }