結果
問題 |
No.680 作れる数
|
ユーザー |
![]() |
提出日時 | 2018-05-03 19:54:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 863 bytes |
コンパイル時間 | 839 ms |
コンパイル使用メモリ | 82,748 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 00:48:19 |
合計ジャッジ時間 | 1,410 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:50:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 50 | scanf("%d", &n); | ~~~~~^~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 680.cc: No.680 作れる数 - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int MAX_T = 500000010; /* typedef */ /* global variables */ /* subroutines */ inline int calc_s(int t) { int s = 0; while (t) { s += t; t >>= 1; } return s; } /* main */ int main() { int n; scanf("%d", &n); int t0 = 0, t1 = MAX_T; while (t0 + 1 < t1) { int t = (t0 + t1) / 2; if (calc_s(t) > n) t1 = t; else t0 = t; } if (calc_s(t0) == n) puts("YES"); else puts("NO"); return 0; }