結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー imulanimulan
提出日時 2016-02-05 20:35:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 999 bytes
コンパイル時間 1,344 ms
コンパイル使用メモリ 143,720 KB
実行使用メモリ 24,408 KB
平均クエリ数 3.70
最終ジャッジ日時 2023-09-23 23:08:39
合計ジャッジ時間 3,859 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
23,676 KB
testcase_01 AC 34 ms
24,408 KB
testcase_02 AC 34 ms
24,336 KB
testcase_03 AC 34 ms
24,012 KB
testcase_04 AC 34 ms
24,024 KB
testcase_05 AC 35 ms
23,604 KB
testcase_06 AC 34 ms
23,520 KB
testcase_07 AC 35 ms
23,520 KB
testcase_08 AC 34 ms
23,364 KB
testcase_09 AC 34 ms
23,376 KB
testcase_10 AC 36 ms
23,976 KB
testcase_11 AC 35 ms
24,348 KB
testcase_12 AC 34 ms
24,012 KB
testcase_13 AC 36 ms
23,400 KB
testcase_14 AC 35 ms
23,520 KB
testcase_15 AC 35 ms
23,364 KB
testcase_16 AC 34 ms
23,376 KB
testcase_17 AC 35 ms
23,340 KB
testcase_18 AC 34 ms
23,412 KB
testcase_19 AC 34 ms
23,388 KB
testcase_20 AC 35 ms
24,036 KB
testcase_21 AC 36 ms
24,012 KB
testcase_22 AC 36 ms
23,652 KB
testcase_23 AC 35 ms
23,784 KB
testcase_24 AC 35 ms
23,508 KB
testcase_25 AC 34 ms
23,628 KB
testcase_26 AC 34 ms
23,352 KB
testcase_27 AC 35 ms
23,340 KB
testcase_28 AC 38 ms
23,376 KB
testcase_29 AC 36 ms
23,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int n,k;
  cin >>n >>k;

  int e; //敵の入力

  if(n-1<=k){//初ターンで勝てる
    cout << n-1 << endl;
    cout <<flush;

    cin >>e;
  }
  else{
    //初手を取るべきか否か
    bool first=true;
    if(n%(k+1)==1) first=false;

    //毎回自分の出力を割った余りはrになるようにする
    int r=n%(k+1);
    if(r==0) r=k+1;
    --r;

    cout << r << endl;
    cout <<flush;

    while(1){
      cin >>e;
      if(e>=n) break;

      int q=e/(k+1);
      int rr=e%(k+1);

      int m=e;
      if(rr<r){
        m+=r-rr;
      }
      else if(rr>r){
        m+=r+k+1-rr;
      }

      cout << m << endl;
      cout <<flush;
    }

  }

  return 0;
}
0