結果

問題 No.2066 Simple Math !
ユーザー okkuukenkenokkuukenken
提出日時 2022-09-02 22:40:12
言語 C++23(draft)
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 833 bytes
コンパイル時間 1,643 ms
コンパイル使用メモリ 149,700 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 04:56:23
合計ジャッジ時間 7,116 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 20 ms
4,380 KB
testcase_02 AC 26 ms
4,376 KB
testcase_03 AC 24 ms
4,376 KB
testcase_04 AC 195 ms
4,376 KB
testcase_05 AC 196 ms
4,380 KB
testcase_06 AC 195 ms
4,380 KB
testcase_07 AC 202 ms
4,376 KB
testcase_08 AC 198 ms
4,380 KB
testcase_09 AC 196 ms
4,376 KB
testcase_10 AC 208 ms
4,380 KB
testcase_11 AC 200 ms
4,376 KB
testcase_12 AC 201 ms
4,376 KB
testcase_13 AC 203 ms
4,376 KB
testcase_14 AC 193 ms
4,380 KB
testcase_15 AC 192 ms
4,384 KB
testcase_16 AC 192 ms
4,376 KB
testcase_17 AC 197 ms
4,376 KB
testcase_18 AC 194 ms
4,376 KB
testcase_19 AC 71 ms
4,380 KB
testcase_20 AC 71 ms
4,380 KB
testcase_21 AC 71 ms
4,380 KB
testcase_22 AC 73 ms
4,380 KB
testcase_23 AC 72 ms
4,380 KB
testcase_24 AC 107 ms
4,376 KB
testcase_25 AC 108 ms
4,376 KB
testcase_26 AC 107 ms
4,380 KB
testcase_27 AC 109 ms
4,380 KB
testcase_28 AC 108 ms
4,380 KB
testcase_29 AC 50 ms
4,376 KB
testcase_30 AC 26 ms
4,380 KB
testcase_31 AC 30 ms
4,380 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