結果

問題 No.1350 2019-6problem
ユーザー mmn15277198mmn15277198
提出日時 2021-01-18 16:51:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 582 bytes
コンパイル時間 499 ms
コンパイル使用メモリ 68,716 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-21 00:14:50
合計ジャッジ時間 1,494 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,376 KB
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

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

ll lcm(ll a , ll b){
	return a / gcd(a , b) * b;
}

int main(){
	ll a , b , k;
	cin >> a >> b >> k;
	ll ok = 3000000000 , ng = 0;
	ll l = lcm(a , b);
	ll mid;
	while(ok - ng > 1){
		mid = (ok + ng) / 2;
		ll now = mid/a + mid/b - mid/l;
		if(now >= k)ok = mid;
		else if(now < k)ng = mid;
		//cout << ok << " : " << ng << " : " << mid << endl;
	}
	cout << ok << endl;
	return 0;
}
0