結果

問題 No.176 2種類の切手
ユーザー uafr_csuafr_cs
提出日時 2015-12-07 00:25:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 136 ms / 1,000 ms
コード長 808 bytes
コンパイル時間 2,126 ms
コンパイル使用メモリ 75,344 KB
実行使用メモリ 41,952 KB
最終ジャッジ日時 2024-04-16 22:20:05
合計ジャッジ時間 7,286 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
41,372 KB
testcase_01 AC 136 ms
41,524 KB
testcase_02 AC 132 ms
41,672 KB
testcase_03 AC 127 ms
41,140 KB
testcase_04 AC 123 ms
41,572 KB
testcase_05 AC 112 ms
40,264 KB
testcase_06 AC 128 ms
41,424 KB
testcase_07 AC 127 ms
41,672 KB
testcase_08 AC 117 ms
41,680 KB
testcase_09 AC 118 ms
41,392 KB
testcase_10 AC 130 ms
41,392 KB
testcase_11 AC 128 ms
41,664 KB
testcase_12 AC 126 ms
41,348 KB
testcase_13 AC 121 ms
40,088 KB
testcase_14 AC 129 ms
41,280 KB
testcase_15 AC 125 ms
41,128 KB
testcase_16 AC 133 ms
41,232 KB
testcase_17 AC 116 ms
41,784 KB
testcase_18 AC 116 ms
41,420 KB
testcase_19 AC 128 ms
41,440 KB
testcase_20 AC 130 ms
41,352 KB
testcase_21 AC 128 ms
41,620 KB
testcase_22 AC 128 ms
41,336 KB
testcase_23 AC 130 ms
41,752 KB
testcase_24 AC 114 ms
41,572 KB
testcase_25 AC 129 ms
41,364 KB
testcase_26 AC 132 ms
41,584 KB
testcase_27 AC 117 ms
41,628 KB
testcase_28 AC 127 ms
41,684 KB
testcase_29 AC 132 ms
41,952 KB
testcase_30 AC 134 ms
41,908 KB
testcase_31 AC 131 ms
41,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long A = sc.nextLong();
		final long B = sc.nextLong();
		final long T = sc.nextLong();
		
		final long max = Math.max(A, B);
		final long min = Math.min(A, B);
		
		Set<Long> hash = new HashSet<Long>();
		long answer = Long.MAX_VALUE;
	
		for(long i = (T + max - 1) / max; i >= 0; i--){
			long value = i * max;
			value += Math.max(0, (T - value + min - 1) / min * min);
			//System.out.println(value);
			
			if(hash.contains(value)){
				break;
			}else{
				answer = Math.min(answer, value);
				hash.add(value);
			}
		}
		
		System.out.println(answer);	
	}

}
0