結果

問題 No.928 軽減税率?
ユーザー 37zigen37zigen
提出日時 2019-11-22 22:53:00
言語 Java19
(openjdk 21)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 1,358 bytes
コンパイル時間 2,212 ms
コンパイル使用メモリ 74,044 KB
実行使用メモリ 57,988 KB
最終ジャッジ日時 2023-08-01 12:41:58
合計ジャッジ時間 8,136 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,452 KB
testcase_01 AC 121 ms
56,048 KB
testcase_02 AC 123 ms
55,676 KB
testcase_03 AC 121 ms
56,068 KB
testcase_04 AC 125 ms
55,524 KB
testcase_05 AC 126 ms
56,072 KB
testcase_06 AC 124 ms
55,756 KB
testcase_07 AC 124 ms
56,004 KB
testcase_08 AC 123 ms
55,740 KB
testcase_09 AC 125 ms
57,988 KB
testcase_10 AC 125 ms
56,008 KB
testcase_11 AC 123 ms
55,800 KB
testcase_12 AC 124 ms
56,116 KB
testcase_13 AC 124 ms
55,784 KB
testcase_14 AC 127 ms
55,748 KB
testcase_15 AC 125 ms
55,616 KB
testcase_16 AC 125 ms
55,672 KB
testcase_17 AC 125 ms
55,920 KB
testcase_18 AC 123 ms
55,932 KB
testcase_19 AC 125 ms
55,512 KB
testcase_20 AC 125 ms
55,464 KB
testcase_21 AC 125 ms
55,960 KB
testcase_22 AC 123 ms
55,816 KB
testcase_23 AC 123 ms
55,752 KB
testcase_24 AC 127 ms
55,760 KB
testcase_25 AC 124 ms
55,752 KB
testcase_26 AC 126 ms
56,072 KB
testcase_27 AC 125 ms
55,580 KB
testcase_28 AC 129 ms
55,768 KB
testcase_29 AC 128 ms
55,752 KB
testcase_30 AC 123 ms
55,772 KB
testcase_31 AC 125 ms
55,652 KB
testcase_32 AC 123 ms
55,712 KB
testcase_33 AC 123 ms
55,972 KB
testcase_34 AC 127 ms
55,976 KB
testcase_35 AC 125 ms
55,860 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