結果

問題 No.176 2種類の切手
ユーザー ttkkggww
提出日時 2022-08-20 02:10:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 4,400 ms
コンパイル使用メモリ 249,996 KB
最終ジャッジ日時 2025-01-31 01:52:35
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
ll a,b,c;

ll f(ll n){
	ll nb = b*n;
	ll d = b - a;
	nb -= min(n,(nb-c)/d)*d;
	return nb;
}

void solve(){
	if(a>b)swap(a,b);
	ll n = (c+b-1)/b;
	ll ans = n*b;
	n--;
	for(int i = n;i<n+100000;i++){
		if(f(i)>=c){
			ans = min(ans,f(i));
		}
	}
	cout<<ans<<endl;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> a >> b >> c;
	solve();
}
0