結果

問題 No.928 軽減税率?
ユーザー goodbatongoodbaton
提出日時 2019-11-29 14:09:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,891 bytes
コンパイル時間 858 ms
コンパイル使用メモリ 100,588 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 22:52:15
合計ジャッジ時間 2,002 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

// GCC __gcd(long long A, long long B)

ll gcd(ll a, ll b){
  if(a == 0) return b;
  return gcd(b%a, a);
}

ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}

const ll e9 = 1000000000;

int main(){
  int P, Q, A;

  cin >> P >> Q >> A;

  int d = P * Q == 0 ? 1 : lcm(P, Q);
  d = lcm(d, 100);

  ll inf = (e9 + d - 1) / d * d;

  if (inf * P <= inf * Q + A) {
    printf("%lld\n", e9);
    return 0;
  }

  // 0 * P 円 < 0 * Q + A円   inf * P円 > inf * Q + A円

  ll l = 0, r = inf / d - 1;

  while (l < r) {
    ll mid = (l + r + 1) / 2;

    if (mid * d * P / 100 < mid * d * Q / 100 + A) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }

  ll ans = l * d - 1;

  debug(ans);

  debug(l * d * P / 100);
  debug(l * d * P / 100);

  for (ll i=l*d; i<(l+1)*d; i++) {
    if (i * P / 100 < i * Q / 100 + A) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}
0