結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー wahr69
提出日時 2015-07-31 23:49:23
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 629 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 60,584 KB
実行使用メモリ 25,220 KB
平均クエリ数 3.70
最終ジャッジ日時 2024-07-16 21:00:00
合計ジャッジ時間 3,928 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	if (N == 1) {
		cout << "0" << endl;
		cout.flush();
		int op;
		cin >> op;
		return 0;
	}

	int turn = 0;
	bool ato = (N % (K + 1) == 1);
	if (ato) {
		cout << "0" << endl;
		cout.flush();
	} else {
		int winNum = (K + 1) * turn + ((N - 1) % (K + 1));

		cout << winNum << endl;
		cout.flush();
	}
	
	while (true) {
		int op;
		cin >> op;
		++turn;

		if (op >= N) {
			return 0;
		}

		int winNum = (K + 1) * turn + ((N - 1) % (K + 1));

		cout << winNum << endl;
		cout.flush();
	}
}
0