結果

問題 No.2259 Gas Station
ユーザー ks2mks2m
提出日時 2023-04-07 21:24:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 707 bytes
コンパイル時間 1,778 ms
コンパイル使用メモリ 74,428 KB
実行使用メモリ 37,280 KB
最終ジャッジ日時 2024-04-10 16:31:43
合計ジャッジ時間 3,633 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
36,976 KB
testcase_01 AC 44 ms
36,992 KB
testcase_02 AC 44 ms
37,224 KB
testcase_03 AC 48 ms
36,720 KB
testcase_04 AC 48 ms
36,988 KB
testcase_05 AC 46 ms
37,132 KB
testcase_06 AC 48 ms
37,188 KB
testcase_07 AC 47 ms
37,164 KB
testcase_08 AC 44 ms
37,256 KB
testcase_09 AC 45 ms
36,720 KB
testcase_10 AC 45 ms
37,280 KB
testcase_11 AC 44 ms
37,160 KB
testcase_12 AC 45 ms
36,712 KB
testcase_13 AC 45 ms
37,224 KB
testcase_14 AC 44 ms
36,932 KB
testcase_15 AC 45 ms
37,168 KB
testcase_16 AC 46 ms
37,204 KB
testcase_17 AC 45 ms
37,036 KB
testcase_18 AC 44 ms
37,280 KB
testcase_19 AC 45 ms
37,020 KB
testcase_20 AC 46 ms
37,216 KB
testcase_21 AC 45 ms
37,180 KB
testcase_22 AC 45 ms
36,844 KB
testcase_23 AC 45 ms
37,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int l = Integer.parseInt(sa[0]);
		int r = Integer.parseInt(sa[1]);
		int c = Integer.parseInt(sa[2]);
		br.close();

		boolean[] b = new boolean[1000];
		for (int i = l; i <= r; i++) {
			int a = (int) ((long) c * i % 1000);
			if (b[a]) {
				break;
			}
			b[a] = true;
		}

		if (b[0]) {
			System.out.println(0);
			return;
		}
		for (int i = 999; i > 0; i--) {
			if (b[i]) {
				System.out.println(1000 - i);
				return;
			}
		}
	}
}
0