結果
問題 | No.176 2種類の切手 |
ユーザー |
![]() |
提出日時 | 2020-05-23 20:01:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 702 bytes |
コンパイル時間 | 1,846 ms |
コンパイル使用メモリ | 157,944 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 22:12:34 |
合計ジャッジ時間 | 3,133 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
/*** @FileName a.cpp* @Author kanpurin* @Created 2020.05.23 20:01:47**/#include "bits/stdc++.h"using namespace std;typedef long long ll;//gcdtemplate<typename T>T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}int main() {ll a,b,t;cin >> a >> b >> t;constexpr long long LLINF = 1e18 + 1;if (t % a == 0 || t % b == 0) {cout << t << endl;}else if (a * b >= t) {ll ans = LLINF;for (int i = 0; i <= (t+b-1)/b; i++) {ans = min(ans,b * i + a * max(0LL,(t-b*i+a-1)/a));}cout << ans << endl;}else {int g = gcd(a,b);cout << (t + g - 1) / g * g << endl;}return 0;}