結果

問題 No.928 軽減税率?
ユーザー yk356yk356
提出日時 2019-11-22 22:27:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,063 bytes
コンパイル時間 1,899 ms
コンパイル使用メモリ 163,340 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 11:58:53
合計ジャッジ時間 7,225 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 TLE -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

double P, Q;
long long A;
long long search(int flag)
{
    long long left = 0;
    long long right = 1e9+1;
    while(right - left > 1)
    {
        long long mid = (left+right)/2;
        long long p = (long long)((double)mid * ((double)1.0 + P/(double)100));
        long long q = (long long)((double)mid * ((double)1.0 + Q/(double)100)) + A;
        if(flag == 1)
        {
            if(p > q) right = mid;
            else left = mid;
        }
        else if(flag == 2)
        {
            if(p >= q-1) right = mid;
            else left = mid;
        }
    }
    return right;
}

int main()
{
    cin >> P >> Q >> A;
    long long top = search(1);
    long long bot = search(2);
    long long cnt = 0;
    for(long long i = bot+1; i <= top; i++)
    {
        long long p = (long long)((double)i*((double)1.0+P/(double)100));
        long long q = (long long)((double)i*((double)1.0+Q/(double)100))+A;
        if(p < q) cnt++;
    }

    long long ans = bot+cnt;
    cout << ans << endl;
    return 0;
}
0