結果
問題 | No.176 2種類の切手 |
ユーザー |
![]() |
提出日時 | 2015-04-03 02:14:24 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 716 bytes |
コンパイル時間 | 646 ms |
コンパイル使用メモリ | 73,192 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-08 02:57:54 |
合計ジャッジ時間 | 1,799 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <iostream>#include <vector>#include <cstdio>#include <sstream>#include <map>#include <string>#include <algorithm>#include <queue>#include <cmath>#include <set>using namespace std;int main(){long long A,B,T;cin >> A >> B >> T;long long k = min(T/(A+B), A*B);long long ans = 1LL<<60;if(T%A==0 || T%B==0) ans = T;if(A>T) ans = min(ans, A);if(B>T) ans = min(ans, B);for(int i=0; i<=k+1; i++){long long rem = ( T%(A+B) + i*(A+B) );if(rem > T) continue;ans = min(ans, (rem/A + (rem%A?1:0) )*A + (T - rem) );ans = min(ans, (rem/B + (rem%B?1:0) )*B + (T - rem) );ans = min(ans, (rem/(A+B) + (rem%(A+B)?1:0) )*(A+B) + (T - rem) );}cout << ans << endl;return 0;}