結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
izuru_matsuura
|
| 提出日時 | 2016-10-04 18:44:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 1,476 bytes |
| コンパイル時間 | 1,616 ms |
| コンパイル使用メモリ | 171,416 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 16:20:23 |
| 合計ジャッジ時間 | 2,473 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#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;
}
const ll INF = LLONG_MAX;
ll calc(ll A, ll B) {
ll r = T % A;
if (r == 0) {
return T;
}
ll ans = INF;
ll b_count = 0;
set<ll> found;
found.insert(r);
for (int i = 0; i < A; i++) {
b_count++;
if (B * b_count > T) {
ans = min(ans, B * b_count);
break;
}
r = next(r);
if (r == 0) {
return T;
}
found.insert(r);
}
auto it = found.end();
it--;
return min(ans, T + A - *it);
}
void solve() {
cout << calc(A, B) << endl;
}
}
int main() {
input(); solve();
return 0;
}
izuru_matsuura