結果
問題 |
No.176 2種類の切手
|
ユーザー |
![]() |
提出日時 | 2020-10-07 17:11:40 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 929 ms / 1,000 ms |
コード長 | 633 bytes |
コンパイル時間 | 2,538 ms |
コンパイル使用メモリ | 75,132 KB |
実行使用メモリ | 41,868 KB |
最終ジャッジ日時 | 2024-07-20 03:27:49 |
合計ジャッジ時間 | 8,934 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
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); } }