結果

問題 No.2066 Simple Math !
ユーザー SSRSSSRS
提出日時 2022-09-02 21:49:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 203,448 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 03:47:06
合計ジャッジ時間 9,256 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 73 ms
4,380 KB
testcase_02 AC 89 ms
4,380 KB
testcase_03 AC 53 ms
4,380 KB
testcase_04 AC 234 ms
4,384 KB
testcase_05 AC 232 ms
4,380 KB
testcase_06 AC 234 ms
4,380 KB
testcase_07 AC 232 ms
4,380 KB
testcase_08 AC 234 ms
4,384 KB
testcase_09 AC 230 ms
4,384 KB
testcase_10 AC 229 ms
4,384 KB
testcase_11 AC 228 ms
4,380 KB
testcase_12 AC 232 ms
4,380 KB
testcase_13 AC 235 ms
4,380 KB
testcase_14 AC 206 ms
4,380 KB
testcase_15 AC 207 ms
4,384 KB
testcase_16 AC 206 ms
4,384 KB
testcase_17 AC 209 ms
4,380 KB
testcase_18 AC 207 ms
4,384 KB
testcase_19 AC 147 ms
4,380 KB
testcase_20 AC 148 ms
4,384 KB
testcase_21 AC 149 ms
4,384 KB
testcase_22 AC 148 ms
4,380 KB
testcase_23 AC 149 ms
4,380 KB
testcase_24 AC 204 ms
4,384 KB
testcase_25 AC 206 ms
4,380 KB
testcase_26 AC 203 ms
4,380 KB
testcase_27 AC 204 ms
4,380 KB
testcase_28 AC 205 ms
4,380 KB
testcase_29 AC 69 ms
4,384 KB
testcase_30 AC 54 ms
4,380 KB
testcase_31 AC 51 ms
4,380 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