結果

問題 No.2066 Simple Math !
ユーザー SSRSSSRS
提出日時 2022-09-02 21:49:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 1,795 ms
コンパイル使用メモリ 206,852 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 21:19:40
合計ジャッジ時間 8,074 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 70 ms
6,816 KB
testcase_02 AC 83 ms
6,940 KB
testcase_03 AC 50 ms
6,944 KB
testcase_04 AC 203 ms
6,940 KB
testcase_05 AC 206 ms
6,940 KB
testcase_06 AC 206 ms
6,944 KB
testcase_07 AC 206 ms
6,940 KB
testcase_08 AC 206 ms
6,940 KB
testcase_09 AC 206 ms
6,940 KB
testcase_10 AC 206 ms
6,940 KB
testcase_11 AC 205 ms
6,944 KB
testcase_12 AC 210 ms
6,940 KB
testcase_13 AC 205 ms
6,940 KB
testcase_14 AC 183 ms
6,944 KB
testcase_15 AC 184 ms
6,940 KB
testcase_16 AC 186 ms
6,944 KB
testcase_17 AC 183 ms
6,940 KB
testcase_18 AC 187 ms
6,940 KB
testcase_19 AC 132 ms
6,940 KB
testcase_20 AC 137 ms
6,944 KB
testcase_21 AC 138 ms
6,940 KB
testcase_22 AC 134 ms
6,940 KB
testcase_23 AC 140 ms
6,940 KB
testcase_24 AC 193 ms
6,940 KB
testcase_25 AC 183 ms
6,940 KB
testcase_26 AC 185 ms
6,940 KB
testcase_27 AC 187 ms
6,940 KB
testcase_28 AC 181 ms
6,944 KB
testcase_29 AC 63 ms
6,944 KB
testcase_30 AC 49 ms
6,940 KB
testcase_31 AC 47 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;
const long long INF = 1000000000000000000;
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    long long P, Q, K;
    cin >> P >> Q >> K;
    long long g = gcd(P, Q);
    P /= g;
    Q /= g;
    long long tv = INF, fv = 0;
    while (tv - fv > 1){
      long long mid = (tv + fv) / 2;
      long long cnt = 0;
      long long N = min(P, mid / Q + 1);
      cnt = atcoder::floor_sum(N, P, -Q, mid + P);
      if (cnt >= K + 1){
        tv = mid;
      } else {
        fv = mid;
      }
    }
    cout << tv * g << endl;
  }
}
0