結果

問題 No.176 2種類の切手
ユーザー cormorancormoran
提出日時 2016-10-04 17:41:27
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,014 bytes
コンパイル時間 1,264 ms
コンパイル使用メモリ 159,984 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 11:42:06
合計ジャッジ時間 5,894 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 115 ms
5,376 KB
testcase_04 AC 113 ms
5,376 KB
testcase_05 AC 115 ms
5,376 KB
testcase_06 AC 115 ms
5,376 KB
testcase_07 AC 116 ms
5,376 KB
testcase_08 AC 114 ms
5,376 KB
testcase_09 AC 115 ms
5,376 KB
testcase_10 AC 114 ms
5,376 KB
testcase_11 AC 114 ms
5,376 KB
testcase_12 AC 113 ms
5,376 KB
testcase_13 AC 114 ms
5,376 KB
testcase_14 AC 113 ms
5,376 KB
testcase_15 AC 113 ms
5,376 KB
testcase_16 AC 113 ms
5,376 KB
testcase_17 AC 113 ms
5,376 KB
testcase_18 AC 115 ms
5,376 KB
testcase_19 AC 115 ms
5,376 KB
testcase_20 AC 113 ms
5,376 KB
testcase_21 AC 114 ms
5,376 KB
testcase_22 AC 115 ms
5,376 KB
testcase_23 AC 114 ms
5,376 KB
testcase_24 AC 114 ms
5,376 KB
testcase_25 AC 114 ms
5,376 KB
testcase_26 WA -
testcase_27 AC 113 ms
5,376 KB
testcase_28 AC 114 ms
5,376 KB
testcase_29 WA -
testcase_30 AC 114 ms
5,376 KB
testcase_31 AC 114 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }

const ll INFL = 1LL << 60;

template<typename T>
T gcd(T a,T b){
    T c=a,d=b,r;
    do{r=c%d;c=d;d=r;}while(r);
    return c;
}

template<typename T>
T lcm(T a,T b){return a*b/gcd(a,b);}


class Solver {
  public:
    bool solve() {
        ll A, B, T; cin >> A >> B >> T;
        ll ans = 0;
        ll lc = lcm(A, B);
        ans += (T / lc) * lc;
        T %= lc;

        ll mini = INFL;
        rep(i, 10000) {
            rep(j, 10000) {
                ll ab = A * i + B * j;
                if(ab >= T) {
                    set_min(mini, ab);
                }
            }
        }
        assert(mini < INFL);
        cout << ans + mini << endl;
        
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}
0