結果

問題 No.2066 Simple Math !
ユーザー pockynypockyny
提出日時 2022-09-03 13:05:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 228 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 81,940 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 11:41:50
合計ジャッジ時間 7,648 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 66 ms
5,376 KB
testcase_02 AC 81 ms
5,376 KB
testcase_03 AC 50 ms
5,376 KB
testcase_04 AC 227 ms
5,376 KB
testcase_05 AC 227 ms
5,376 KB
testcase_06 AC 228 ms
5,376 KB
testcase_07 AC 228 ms
5,376 KB
testcase_08 AC 226 ms
5,376 KB
testcase_09 AC 228 ms
5,376 KB
testcase_10 AC 227 ms
5,376 KB
testcase_11 AC 227 ms
5,376 KB
testcase_12 AC 225 ms
5,376 KB
testcase_13 AC 228 ms
5,376 KB
testcase_14 AC 204 ms
5,376 KB
testcase_15 AC 203 ms
5,376 KB
testcase_16 AC 203 ms
5,376 KB
testcase_17 AC 205 ms
5,376 KB
testcase_18 AC 205 ms
5,376 KB
testcase_19 AC 142 ms
5,376 KB
testcase_20 AC 142 ms
5,376 KB
testcase_21 AC 141 ms
5,376 KB
testcase_22 AC 143 ms
5,376 KB
testcase_23 AC 143 ms
5,376 KB
testcase_24 AC 200 ms
5,376 KB
testcase_25 AC 201 ms
5,376 KB
testcase_26 AC 205 ms
5,376 KB
testcase_27 AC 199 ms
5,376 KB
testcase_28 AC 199 ms
5,376 KB
testcase_29 AC 63 ms
5,376 KB
testcase_30 AC 52 ms
5,376 KB
testcase_31 AC 59 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/math>

using namespace std;
using namespace atcoder;
typedef long long ll;
ll gcd(ll a,ll b){
    if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(a%b,b);
}

int main(){
    int t; cin >> t;
    while(t){
        t--;
        ll p,q,k; cin >> p >> q >> k;
        ll g = gcd(p,q); p /= g; q /= g;
        ll le = 0,ri = 1000000000000000000;
        while(ri - le>1){
            ll mid = (le + ri)/2;
            ll n = min(mid/p,q - 1);
            if(floor_sum(n + 1,q,p,mid + q - n*p)>=k + 1) ri = mid;
            else le = mid;
        }
        cout << g*ri << "\n";
    }
}
0