結果
| 問題 | 
                            No.176 2種類の切手
                             | 
                    
| コンテスト | |
| ユーザー | 
                             nakacity_people
                         | 
                    
| 提出日時 | 2015-04-02 23:52:51 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 678 bytes | 
| コンパイル時間 | 730 ms | 
| コンパイル使用メモリ | 67,520 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-10-08 01:44:55 | 
| 合計ジャッジ時間 | 2,575 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 WA * 4 | 
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
using namespace std;
int ans = 0x7fffffff;
int sum = 0;
int A, B, T;
void setSum(int _sum) {
	sum = _sum;
	if ( sum < ans && T <= sum ) ans = sum;
}
int main() {
	cin >> A >> B >> T;
	if ( T % A == 0 || T % B == 0 ) {
		return T;
	}
	int count = (T / A) + 1;
	
	setSum( A * count );
	REP(i, count) {
		int next = sum - A;
		while (next < T) next += B;
		setSum( next );
		if ( sum == T ) break;
	}
	cout << ans << endl;
	return 0;
}
            
            
            
        
            
nakacity_people