結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
nakacity_people
|
| 提出日時 | 2015-04-02 23:59:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 577 ms / 1,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 598 ms |
| コンパイル使用メモリ | 67,692 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-08 01:50:31 |
| 合計ジャッジ時間 | 2,147 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int ans = 0x7fffffff;
int sum = 0;
int A, B, T;
void setSum(int _sum) {
sum = _sum;
if ( sum < ans && T <= sum ) ans = sum;
}
int main() {
cin >> A >> B >> T;
if ( T % A == 0 || T % B == 0 ) {
cout << T << endl;
return T;
}
int count = (T / A) + 1;
setSum( A * count );
while ( count-- ) {
int next = sum - A;
while (next < T) next += B;
setSum( next );
if ( sum == T ) break;
}
cout << ans << endl;
return 0;
}
nakacity_people