結果
問題 | No.176 2種類の切手 |
ユーザー |
![]() |
提出日時 | 2015-04-03 00:45:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 1,005 bytes |
コンパイル時間 | 1,462 ms |
コンパイル使用メモリ | 160,384 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-08 02:50:22 |
合計ジャッジ時間 | 2,635 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
#include <bits/stdc++.h>#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)const int dx[] = {1, 0, -1, 0};const int dy[] = {0, 1, 0, -1};using namespace std;typedef long long ll;const ll INF = 1ll<<51;ll dist[2200];int main() {ll A, B, T;cin >> A >> B >> T;if (B >= 1000) {ll ans = INF;for (ll i = 0; i <= 1000000; i++) {ll rest = T-i*B;if (rest < 0) ans = min(ans, i*B);else {ll tmp = rest/A*A+i*B;if (tmp < T) tmp += A;ans = min(ans, tmp);}}cout << ans << endl;} else {for (int i = 0; i < 2200; i++) dist[i] = INF;for (ll i = 0; i < 2200; i++) {ll m = (A*i)%B;dist[m] = min(dist[m], i);}while (1) {ll m = T % B;if (A*dist[m] <= T) {cout << T << endl;break;}T++;}}return 0;}