結果

問題 No.176 2種類の切手
ユーザー tentententen
提出日時 2020-10-07 17:11:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 753 ms / 1,000 ms
コード長 633 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 71,772 KB
実行使用メモリ 56,360 KB
最終ジャッジ日時 2023-09-27 09:19:27
合計ジャッジ時間 8,634 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,700 KB
testcase_01 AC 108 ms
55,632 KB
testcase_02 AC 109 ms
55,632 KB
testcase_03 AC 109 ms
56,084 KB
testcase_04 AC 111 ms
56,184 KB
testcase_05 AC 115 ms
55,680 KB
testcase_06 AC 110 ms
55,984 KB
testcase_07 AC 116 ms
56,012 KB
testcase_08 AC 116 ms
55,512 KB
testcase_09 AC 108 ms
55,464 KB
testcase_10 AC 110 ms
55,536 KB
testcase_11 AC 112 ms
56,044 KB
testcase_12 AC 111 ms
55,700 KB
testcase_13 AC 110 ms
56,120 KB
testcase_14 AC 110 ms
56,324 KB
testcase_15 AC 111 ms
56,100 KB
testcase_16 AC 110 ms
55,448 KB
testcase_17 AC 108 ms
55,772 KB
testcase_18 AC 111 ms
55,660 KB
testcase_19 AC 111 ms
55,648 KB
testcase_20 AC 113 ms
55,892 KB
testcase_21 AC 115 ms
55,976 KB
testcase_22 AC 753 ms
55,704 KB
testcase_23 AC 116 ms
55,836 KB
testcase_24 AC 114 ms
56,176 KB
testcase_25 AC 111 ms
56,152 KB
testcase_26 AC 109 ms
56,360 KB
testcase_27 AC 110 ms
56,360 KB
testcase_28 AC 118 ms
55,544 KB
testcase_29 AC 115 ms
55,792 KB
testcase_30 AC 112 ms
55,696 KB
testcase_31 AC 112 ms
55,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int t = sc.nextInt();
		if (t % a == 0 || t % b == 0) {
		    System.out.println(t);
		    return;
		}
		int count = 0;
		int min = Integer.MAX_VALUE;
		while (count * b < t) {
            min = Math.min(min, (t - count * b + a - 1) / a * a + count * b);
            if (min == t) {
                System.out.println(t);
                return;
            }
            count++;
		}
		min = Math.min(min, (t + b - 1) / b * b);
		System.out.println(min);
	}
}
0