結果

問題 No.2526 Kth Not-divisible Number
ユーザー cho435cho435
提出日時 2023-11-03 22:06:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 5,053 ms
コンパイル使用メモリ 262,340 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-03 22:06:57
合計ジャッジ時間 9,953 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

int main(){
	int t;
	cin>>t;
	rep(Ti,t){
		ll a,b,k;
		cin>>a>>b>>k;
		ll l=a/gcd(a,b)*b;
		ll up=7e18;
		ll dw=0;
		while(up-dw>1){
			ll md=(up+dw)/2;
			ll ct=0;
			ct+=md/a;
			ct+=md/b;
			ct-=md/l;
			if(md-ct>k) up=md;
			else dw=md;
		}
		cout<<dw<<"\n";
	}
}
0