結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-10-04 18:41:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,353 bytes |
| コンパイル時間 | 1,435 ms |
| コンパイル使用メモリ | 172,360 KB |
| 実行使用メモリ | 291,648 KB |
| 最終ジャッジ日時 | 2024-11-21 16:19:00 |
| 合計ジャッジ時間 | 8,448 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 1 TLE * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef double real;
typedef long long ll;
template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
if (vs.empty()) return os << "[]";
auto i = vs.begin();
os << "[" << *i;
for (++i; i != vs.end(); ++i) os << " " << *i;
return os << "]";
}
template<class T> istream& operator>>(istream& is, vector<T>& vs) {
for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
return is;
}
ll A, B, T;
void input() {
cin >> A >> B >> T;
}
ll next(ll r) {
ll d = B % A;
ll ans = r - d;
if (ans < 0) ans += A;
return ans;
}
ll calc(ll A, ll B) {
ll r = T % A;
if (r == 0) {
return T;
}
ll b_count = 0;
set<ll> found;
found.insert(r);
for (int i = 0; i < A; i++) {
b_count++;
if (B * b_count > T) break;
r = next(r);
if (r == 0) {
return T;
}
found.insert(r);
}
auto it = found.end();
it--;
return T + A - *it;
}
void solve() {
cout << min(calc(A, B), calc(B, A)) << endl;
}
}
int main() {
input(); solve();
return 0;
}
izuru_matsuura