結果

問題 No.2259 Gas Station
ユーザー ks2m
提出日時 2023-04-07 21:24:23
言語 Java
(openjdk 23)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 707 bytes
コンパイル時間 3,575 ms
コンパイル使用メモリ 73,608 KB
実行使用メモリ 37,428 KB
最終ジャッジ日時 2024-10-02 18:56:38
合計ジャッジ時間 4,943 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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