結果

問題 No.2526 Kth Not-divisible Number
ユーザー keisuke6keisuke6
提出日時 2023-11-03 21:53:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 405 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 202,356 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 21:53:58
合計ジャッジ時間 6,757 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 438 ms
4,348 KB
testcase_04 AC 436 ms
4,348 KB
testcase_05 AC 436 ms
4,348 KB
testcase_06 AC 438 ms
4,348 KB
testcase_07 AC 439 ms
4,348 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int T;
	cin>>T;
	while(T--){
		int a,b,k;
		cin>>a>>b>>k;
		int t = lcm(a,b);
		int ad = (k/(t-t/a-t/b+1))*t;
		k %= (t-t/a-t/b+1);
		if(k == 0){
			cout<<ad-1<<endl;
			continue;
		}
		int l = 1, r = t;
		while(r-l > 1){
			int md = (l+r)/2;
			if(md-md/a-md/b <= k) l = md;
			else r = md;
		}
		cout<<ad+l<<endl;
	}
}
0