結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
nakacity_people
|
| 提出日時 | 2015-05-31 14:50:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 856 bytes |
| コンパイル時間 | 632 ms |
| コンパイル使用メモリ | 67,748 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-08 03:22:33 |
| 合計ジャッジ時間 | 1,674 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 RE * 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 ( A > B ) swap(A, B);
long long gcd = __gcd(A, B);
long long lcm = A * B / gcd;
if ( T / B > 1000000 ) {
int m = (T - lcm) / gcd + ( ((T - lcm) % gcd > 0) ? 1 : 0 );
cout << lcm + m * gcd << endl;
return 1;
}
int count = (T / A) + 1;
setSum( A * count );
while ( count-- ) {
int next = sum - A;
while (next < T) next += B;
setSum( next );
if ( sum == T ) break;
}
cout << ans << endl;
return 0;
}
nakacity_people