結果

問題 No.2066 Simple Math !
ユーザー okkuukenkenokkuukenken
提出日時 2022-09-02 22:40:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 151,548 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 22:15:55
合計ジャッジ時間 6,189 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 19 ms
6,944 KB
testcase_02 AC 25 ms
6,940 KB
testcase_03 AC 24 ms
6,940 KB
testcase_04 AC 183 ms
6,944 KB
testcase_05 AC 180 ms
6,940 KB
testcase_06 AC 181 ms
6,944 KB
testcase_07 AC 186 ms
6,944 KB
testcase_08 AC 196 ms
6,940 KB
testcase_09 AC 191 ms
6,940 KB
testcase_10 AC 186 ms
6,940 KB
testcase_11 AC 188 ms
6,940 KB
testcase_12 AC 192 ms
6,944 KB
testcase_13 AC 191 ms
6,940 KB
testcase_14 AC 184 ms
6,940 KB
testcase_15 AC 182 ms
6,940 KB
testcase_16 AC 180 ms
6,940 KB
testcase_17 AC 181 ms
6,944 KB
testcase_18 AC 182 ms
6,944 KB
testcase_19 AC 67 ms
6,940 KB
testcase_20 AC 67 ms
6,944 KB
testcase_21 AC 66 ms
6,944 KB
testcase_22 AC 68 ms
6,940 KB
testcase_23 AC 67 ms
6,944 KB
testcase_24 AC 102 ms
6,940 KB
testcase_25 AC 103 ms
6,940 KB
testcase_26 AC 101 ms
6,940 KB
testcase_27 AC 106 ms
6,944 KB
testcase_28 AC 106 ms
6,944 KB
testcase_29 AC 50 ms
6,940 KB
testcase_30 AC 27 ms
6,940 KB
testcase_31 AC 28 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<random>
#include<bitset>
#include<cassert>
#include<complex>
#include<fstream>
#include<cstdlib>
#include<functional>
#include<array>
#include<atcoder/math>
using namespace std;
using namespace atcoder;
typedef long long ll;
const int mod=998244353;
int main(){
	int t,p,q,k;
	cin>>t;
	while(cin>>p>>q>>k){
		int g=gcd(p,q);
		p/=g,q/=g;
		ll cnt=floor_sum(p,p,q,p+q-1);
		if(k>=cnt)
			cout<<(k-cnt+(ll)p*q)*g<<endl;
		else{
			ll ub=(ll)p*q,lb=0;
			while(ub-lb>1){
				ll mid=(ub+lb)/2;
				cnt=floor_sum((mid+q-1)/q,p,q,(mid+q-1)%q+p);
				(cnt>k?ub:lb)=mid;
			}
			cout<<lb*g<<endl;
		}
	}
}
0