結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー ぴろず
提出日時 2015-07-31 22:43:39
言語 Java
(openjdk 23)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 2,216 ms
コンパイル使用メモリ 75,040 KB
実行使用メモリ 58,392 KB
平均クエリ数 3.70
最終ジャッジ日時 2024-07-16 20:55:10
合計ジャッジ時間 10,870 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

package no257;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = 0;
		int k = sc.nextInt();
		if ((n - 1) % (k + 1) == 0) {
			System.out.println(0);
			x = sc.nextInt();
			if (x >= n) {
				return;
			}
		}
		while(true) {
			System.out.println(n - 1 - (n - 1 - x) / (k + 1) * (k + 1));
			x = sc.nextInt();
			if (x >= n) {
				break;
			}
		}
	}

}
0