結果
| 問題 | 
                            No.176 2種類の切手
                             | 
                    
| コンテスト | |
| ユーザー | 
                             btk
                         | 
                    
| 提出日時 | 2015-04-03 02:28:09 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,675 bytes | 
| コンパイル時間 | 718 ms | 
| コンパイル使用メモリ | 83,480 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-08 02:58:00 | 
| 合計ジャッジ時間 | 1,756 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 27 WA * 2 | 
ソースコード
#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>
using namespace std;
#define reE(i,a,b) for(auto (i)=(a);(i)<=(b);(i)++)
#define rE(i,b) reE(i,0,b)
#define reT(i,a,b) for(auto (i)=(a);(i)<(b);(i)++)
#define rT(i,b) reT(i,0,b)
#define rep(i,a,b) reE(i,a,b);
#define rev(i,a,b) for(auto (i)=(b)-1;(i)>=(a);(i)--)
#define fe(i,b) for (auto &(x):b);
#define itr(i,b) for(auto (i)=(b).begin();(i)!=(b).end();++(i))
#define rti(i,b) for(auto (i)=(b).rbegin();(i)!=(b).rend();++(i))
#define LL long long
#define all(b) (b).begin(),(b).end()
#define input_init stringstream ss; string strtoken, token; istringstream is
#define input_line  getline(cin, strtoken);is.str(strtoken);is.clear(istringstream::goodbit)
#define input_token(num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num
#define dir(xx,yy,x,y,i) (xx)=(x)+dir[(i)],(yy)=(y)+dir[(i)+1]
typedef complex<double> P;
typedef vector<P> Poly;
const LL INF = 1 << 30;
const double eps = 1e-8;
const int dir[] = { 0, 1, 0, -1, 0 };
LL gcd(LL x, LL y)
{
	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
LL lcm(LL x, LL y){
	return(x*y / gcd(x, y));
}
int main(void){
	LL t, A, B, T,res;
	cin >> A >> B >> T;
	t = T%lcm(A, B);
	if (A > B)swap(A, B);
	LL b = t / B + 1;
	res = b*B;
	while (b > 0){
		b--;
		LL a = max(0ll, (t - b*B+A-1) / A);
		res = min(a *A + b*B, res);
	}
	cout << res + T - t << endl;
	return(0);
}
            
            
            
        
            
btk