結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー imulanimulan
提出日時 2016-02-05 20:34:46
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,073 bytes
コンパイル時間 1,156 ms
コンパイル使用メモリ 144,044 KB
実行使用メモリ 24,336 KB
平均クエリ数 3.70
最終ジャッジ日時 2023-09-23 08:50:33
合計ジャッジ時間 4,329 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
24,096 KB
testcase_01 AC 45 ms
24,324 KB
testcase_02 AC 45 ms
24,072 KB
testcase_03 AC 45 ms
23,712 KB
testcase_04 AC 44 ms
23,676 KB
testcase_05 AC 45 ms
23,652 KB
testcase_06 AC 44 ms
23,592 KB
testcase_07 WA -
testcase_08 AC 45 ms
23,460 KB
testcase_09 AC 46 ms
24,096 KB
testcase_10 AC 47 ms
24,084 KB
testcase_11 AC 46 ms
23,868 KB
testcase_12 AC 44 ms
23,412 KB
testcase_13 AC 44 ms
23,448 KB
testcase_14 AC 46 ms
23,568 KB
testcase_15 AC 46 ms
23,448 KB
testcase_16 AC 45 ms
24,168 KB
testcase_17 AC 46 ms
23,940 KB
testcase_18 AC 45 ms
23,712 KB
testcase_19 AC 46 ms
24,336 KB
testcase_20 AC 46 ms
23,856 KB
testcase_21 AC 45 ms
23,412 KB
testcase_22 AC 46 ms
23,568 KB
testcase_23 AC 45 ms
24,324 KB
testcase_24 AC 45 ms
23,592 KB
testcase_25 AC 44 ms
24,060 KB
testcase_26 AC 44 ms
23,700 KB
testcase_27 AC 45 ms
24,108 KB
testcase_28 AC 45 ms
24,072 KB
testcase_29 AC 45 ms
23,448 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){
    cout << 0 << endl;
    cout <<flush;

    cin >>e;
  }
  else if(n-1<=k){//初ターンで勝てる
    cout << n << 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