結果

問題 No.176 2種類の切手
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-25 20:57:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 1,000 ms
コード長 1,416 bytes
コンパイル時間 2,416 ms
コンパイル使用メモリ 77,700 KB
実行使用メモリ 57,616 KB
最終ジャッジ日時 2023-10-23 21:41:38
合計ジャッジ時間 7,958 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
56,664 KB
testcase_01 AC 123 ms
57,380 KB
testcase_02 AC 128 ms
57,512 KB
testcase_03 AC 124 ms
57,440 KB
testcase_04 AC 120 ms
57,312 KB
testcase_05 AC 110 ms
56,196 KB
testcase_06 AC 119 ms
57,072 KB
testcase_07 AC 122 ms
55,440 KB
testcase_08 AC 122 ms
57,428 KB
testcase_09 AC 113 ms
56,236 KB
testcase_10 AC 123 ms
57,460 KB
testcase_11 AC 111 ms
54,200 KB
testcase_12 AC 113 ms
54,160 KB
testcase_13 AC 112 ms
56,228 KB
testcase_14 AC 122 ms
57,552 KB
testcase_15 AC 115 ms
56,184 KB
testcase_16 AC 111 ms
56,208 KB
testcase_17 AC 126 ms
57,136 KB
testcase_18 AC 118 ms
56,208 KB
testcase_19 AC 124 ms
57,264 KB
testcase_20 AC 116 ms
56,248 KB
testcase_21 AC 120 ms
57,272 KB
testcase_22 AC 111 ms
56,292 KB
testcase_23 AC 124 ms
57,404 KB
testcase_24 AC 116 ms
56,216 KB
testcase_25 AC 123 ms
57,616 KB
testcase_26 AC 113 ms
56,168 KB
testcase_27 AC 122 ms
57,472 KB
testcase_28 AC 112 ms
56,052 KB
testcase_29 AC 113 ms
56,208 KB
testcase_30 AC 123 ms
56,272 KB
testcase_31 AC 121 ms
57,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong();
    long b = sc.nextLong();
    long t = sc.nextLong();
    long ans = (long)Math.pow(10, 15);
    if(a <= 1000000) {
      for(int i = 0; i < a; i++) {
        if(b * i >= t) {
          ans = Math.min(ans, b * i);
        } else {
          long c = t - b * i;
          if(c % a == 0) {
            ans = t;
          } else {
            long d = a * (c / a + 1);
            ans = Math.min(ans, b * i + d);
          }
        }
      }
    } else {
      if(b <= 1000000) {
        for(int i = 0; i < b; i++) {
          if(a * i >= t) {
            ans = Math.min(ans, a * i);
          } else {
            long c = t - a * i;
            if(c % b == 0) {
              ans = t;
            } else {
              long d = b * (c / b + 1);
              ans = Math.min(ans, a * i + d);
            }
          }
        }        
      } else {
        for(int i = 0; i < 10000; i++) {
          if(b * i >= t) {
            ans = Math.min(ans, b * i);
          } else {
            long c = t - b * i;
            if(c % a == 0) {
              ans = t;
            } else {
              long d = a * (c / a + 1);
              ans = Math.min(ans, b * i + d);
            }
          }
        }        
      }
    }
    System.out.println(ans);
  }
}
0