結果

問題 No.176 2種類の切手
ユーザー EmKjpEmKjp
提出日時 2015-04-02 23:37:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,721 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 81,972 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-16 21:23:34
合計ジャッジ時間 1,543 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<numeric>
#include<functional>
#include<complex>
#include<cassert>

using namespace std;
#define BET(a,b,c) ((a)<=(b)&&(b)<(c))
#define FOR(i,n) for(int i=0,i##_end=(int(n));i<i##_end;i++)
#define SZ(x) (int)(x.size())
#define ALL(x) (x).begin(),(x).end()
#define MP make_pair
#define CLS(x,val) memset((x) , val , sizeof(x)) 
#define FOR_EACH(it,v) for(__typeof(v.begin()) it=v.begin(),it_end=v.end() ; it != it_end ; it++)
typedef long long ll_t;
typedef long double ld_t;
typedef vector<int> VI;
typedef vector<VI> VVI;

long long gcd (long long s , long long t) { return t ? gcd(t,s%t) : s ; }
long long lcm (long long s, long long t) { return s / gcd(s, t) * t; }

int main()
{
    int A,B,T;
    cin>>A>>B>>T;
    long long ans = 1LL<<60;
    long long lower = -1, upper = 1LL<<30;
    while(lower < upper - 2){
        ll_t mid1 = (lower + lower + upper) / 3;
        ll_t mid2 = (lower + upper + upper) / 3;
        long long x1 = A * mid1;
        long long rem1 = T - x1;
        if(rem1 > 0) {
            long long need = (rem1 - 1) / B + 1;
            x1 += need * B;
        }

        long long x2 = A * mid2;
        long long rem2 = T - x2;
        if(rem2 > 0) {
            long long need = (rem2 - 1) / B + 1;
            x2 += need * B;
        }
        assert(x1 >= T);
        assert(x2 >= T);

        ans = min(ans, min(x1, x2));

        if(x1 <= x2){
            upper = mid2;
        }else {
            lower = mid1;
        }
        
    }

    cout<<ans<<endl;
    return 0;
}
0