結果

問題 No.928 軽減税率?
ユーザー 37zigen37zigen
提出日時 2019-11-22 22:53:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 1,000 ms
コード長 1,358 bytes
コンパイル時間 1,921 ms
コンパイル使用メモリ 77,132 KB
実行使用メモリ 54,452 KB
最終ジャッジ日時 2024-04-19 12:15:57
合計ジャッジ時間 6,698 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
54,108 KB
testcase_01 AC 98 ms
53,368 KB
testcase_02 AC 108 ms
54,048 KB
testcase_03 AC 110 ms
54,172 KB
testcase_04 AC 98 ms
52,740 KB
testcase_05 AC 106 ms
53,848 KB
testcase_06 AC 106 ms
54,124 KB
testcase_07 AC 109 ms
54,004 KB
testcase_08 AC 100 ms
52,956 KB
testcase_09 AC 108 ms
53,904 KB
testcase_10 AC 109 ms
54,020 KB
testcase_11 AC 99 ms
53,028 KB
testcase_12 AC 109 ms
53,908 KB
testcase_13 AC 101 ms
52,992 KB
testcase_14 AC 107 ms
53,860 KB
testcase_15 AC 99 ms
52,812 KB
testcase_16 AC 103 ms
53,008 KB
testcase_17 AC 111 ms
54,044 KB
testcase_18 AC 115 ms
53,800 KB
testcase_19 AC 116 ms
54,452 KB
testcase_20 AC 104 ms
52,828 KB
testcase_21 AC 103 ms
52,660 KB
testcase_22 AC 99 ms
52,684 KB
testcase_23 AC 110 ms
53,864 KB
testcase_24 AC 118 ms
54,128 KB
testcase_25 AC 113 ms
54,052 KB
testcase_26 AC 106 ms
54,176 KB
testcase_27 AC 97 ms
53,024 KB
testcase_28 AC 104 ms
53,664 KB
testcase_29 AC 102 ms
53,036 KB
testcase_30 AC 112 ms
53,852 KB
testcase_31 AC 113 ms
54,056 KB
testcase_32 AC 103 ms
53,044 KB
testcase_33 AC 106 ms
54,116 KB
testcase_34 AC 111 ms
53,868 KB
testcase_35 AC 100 ms
52,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
import java.io.*;

class Main
{
    public static void main(String[] args)
    {
        new Main().run();
    }
    
    long MAX = (long) 1e9;
    
    void run() {
        Scanner sc = new Scanner(System.in);
        long P = sc.nextLong();
        long Q = sc.nextLong();
        long A = sc.nextLong();
        System.out.println(solve(P, Q, A));
    }
    
    long exact(long P, long Q, long A) {
        long ans = 0;
        for (long x = 1; x <= MAX; ++x) {
            if ((P + 100) * x / 100  < (Q + 100) * x / 100 + A ) ++ans;
        }
        return ans;
    }
    
    long solve(long P, long Q, long A) {
        if (P == Q) {
            if (A == 0) return 0;
            else return MAX;
        }
        if (P < Q) {
            long v = Math.max(1, 100 * ( 1 - A) / (Q - P) + 1);
            long ans = MAX - v;
            for (long x = 1; x <= v; ++x) 
                if ((P + 100) * x / 100  < (Q + 100) * x / 100 + A ) ++ans;
            return ans;
        }
        if (A == 0) {
            return 0;
        }
        
        long ans = Math.max(0, (A - 1) * 100 / (P - Q) - 1);
        for (long x = Math.max(1, (A - 1) * 100 / (P - Q)); x <= (A + 1) * 100 / (P - Q); ++x) {
            if ((P + 100) * x / 100  < (Q + 100) * x / 100 + A ) ++ans;
        }
        return ans;
    }
}
0