結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー nanasilinanasili
提出日時 2015-07-31 23:18:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 932 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 24,336 KB
平均クエリ数 3.70
最終ジャッジ日時 2023-09-23 21:07:33
合計ジャッジ時間 3,485 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
24,276 KB
testcase_01 AC 39 ms
23,412 KB
testcase_02 AC 43 ms
23,688 KB
testcase_03 AC 38 ms
24,276 KB
testcase_04 AC 38 ms
23,568 KB
testcase_05 AC 39 ms
23,664 KB
testcase_06 AC 40 ms
23,664 KB
testcase_07 AC 39 ms
23,688 KB
testcase_08 AC 39 ms
24,312 KB
testcase_09 AC 39 ms
23,856 KB
testcase_10 AC 40 ms
23,664 KB
testcase_11 AC 40 ms
23,412 KB
testcase_12 AC 38 ms
23,856 KB
testcase_13 AC 38 ms
24,336 KB
testcase_14 AC 40 ms
23,424 KB
testcase_15 AC 41 ms
23,460 KB
testcase_16 AC 38 ms
24,336 KB
testcase_17 AC 38 ms
24,060 KB
testcase_18 AC 38 ms
24,312 KB
testcase_19 AC 39 ms
23,664 KB
testcase_20 AC 39 ms
23,556 KB
testcase_21 AC 38 ms
23,268 KB
testcase_22 AC 39 ms
23,424 KB
testcase_23 AC 39 ms
23,460 KB
testcase_24 AC 40 ms
24,312 KB
testcase_25 AC 39 ms
23,688 KB
testcase_26 AC 37 ms
23,652 KB
testcase_27 AC 40 ms
24,288 KB
testcase_28 AC 38 ms
24,048 KB
testcase_29 AC 39 ms
23,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
  }
}
0