結果

問題 No.915 Plus Or Multiple Operation
ユーザー htensaihtensai
提出日時 2020-01-22 10:23:12
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 851 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 75,404 KB
実行使用メモリ 68,216 KB
最終ジャッジ日時 2024-04-24 18:55:14
合計ジャッジ時間 8,600 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[]  args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            long b = sc.nextInt();
            int c = sc.nextInt();
            long total = 0;
            while (a >= 2 * c) {
                if (a % c != 0) {
                    total++;
                    a = a / c * c;
                } else {
                    a /= Math.min(c, a / c);
                    total++;
                }
            }
            if (a >= c) {
                total += 2;
            } else {
                total++;
            }
            sb.append(total * b).append("\n");
        }
        System.out.println(sb);
    }
}
0