結果
問題 |
No.257 N言っちゃダメゲーム (3)
|
ユーザー |
![]() |
提出日時 | 2015-07-31 23:18:05 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 56 ms / 2,000 ms |
コード長 | 932 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 82,052 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 3.70 |
最終ジャッジ日時 | 2024-07-16 20:57:13 |
合計ジャッジ時間 | 3,882 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:31:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf("%lld %lld", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:35:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | scanf("%lld", &n); | ~~~~~^~~~~~~~~~~~ main.cpp:43:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 43 | scanf("%lld", &r); | ~~~~~^~~~~~~~~~~~ main.cpp:53:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 53 | scanf("%lld", &r); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <algorithm> #include <vector> #include <cfloat> #include <string> #include <cmath> #include <set> #include <cstdlib> #include <map> #include <ctime> #include <iomanip> #include <functional> #include <deque> #include <iostream> #include <cstring> #include <queue> #include <cstdio> #include <stack> #include <climits> #include <sys/time.h> #include <cctype> using namespace std; typedef long long ll; int main() { char buf[1000]; setbuf(stdout, buf); ll n, k; scanf("%lld %lld", &n, &k); if (n-1 <= k) { printf("%lld\n", n-1); fflush(stdout); scanf("%lld", &n); return 0; } ll r = 0; if (n%(k+1) == 1) { puts("0"); fflush(stdout); scanf("%lld", &r); } ll p = (n-1)%(k+1); while (r < n) { if ((r+k-p)/(k+1)*(k+1)+p <= r) { printf("%lld\n", r+1); }else { printf("%lld\n", (r+k-p)/(k+1)*(k+1)+p); } fflush(stdout); scanf("%lld", &r); } }