結果

問題 No.1350 2019-6problem
ユーザー mmn15277198mmn15277198
提出日時 2021-01-18 16:29:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 705 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 68,960 KB
実行使用メモリ 8,232 KB
最終ジャッジ日時 2023-08-20 23:59:24
合計ジャッジ時間 5,274 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
		//	else break;
		//cout << ok << " : " << ng << " : " << mid << endl;
	}
	for(ll i = ng; i >= 1; i--){
		ll now = i/a + i/b - i/l;
		if(now == k - 1){
			cout << i + 1 << endl;
			return 0;
		}
	}
		
	return 0;
}
0