結果

問題 No.2526 Kth Not-divisible Number
ユーザー otamay6otamay6
提出日時 2023-11-04 13:36:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 830 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 69,852 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-04 13:36:56
合計ジャッジ時間 8,336 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<numeric>

using ll = unsigned long long;

int main(void){
	int t;
	std::cin>>t;
	while(t--){
		ll a, b, k;
		std::cin>>a>>b>>k;
		ll l = 0, r = 4e18 + 100;
		while(l + 1 < r){
			ll m = (l+r) / 2;
			ll cnt = m - m/ a - m / b + m / std::lcm(a,b);
			if(cnt >=k){
				r = m;
			}
			else{
				l = m;
			}
		}
		std::cout << r << std::endl;
	}
}
0