結果

問題 No.176 2種類の切手
ユーザー t8m8⛄️
提出日時 2015-04-04 08:53:45
言語 Java
(openjdk 23)
結果
AC  
実行時間 143 ms / 1,000 ms
コード長 1,015 bytes
コンパイル時間 4,128 ms
コンパイル使用メモリ 78,868 KB
実行使用メモリ 41,836 KB
最終ジャッジ日時 2024-10-08 03:07:24
合計ジャッジ時間 9,232 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

//No.176 2種類の切手

import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class No176 {
    
    static final Scanner sc = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int t = sc.nextInt();
        long min = Long.MAX_VALUE;
        if (a > b) {
            int temp = a; a = b; b = temp;
        }

        for (int i=0; ; i++) {
            int j = (t-b*i+a-1)/a;
            min = min(min,b*i+a*j);
            if (b*i > t || i > a) break;
        }

        out.println(min);
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        sc.close();
    }

    static void trace(Object... o) { System.out.println(deepToString(o));}
}
0