結果
| 問題 |
No.176 2種類の切手
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-05 01:34:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 641 bytes |
| コンパイル時間 | 568 ms |
| コンパイル使用メモリ | 54,364 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 17:02:17 |
| 合計ジャッジ時間 | 1,505 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#include <iostream>
using namespace std;
int main(){
long A,B,T,N,result = 10000000000;
int A_times,B_times,ab_times=0; //T=A*B*ab_times+N | N < A*B
cin >> A>>B>>T;
ab_times = T/(A*B);
if(ab_times>1)ab_times--;
N = T-A*B*ab_times;
for(B_times = 0;B*B_times<N+B;B_times++){
A_times = (N-B*B_times)/A;
if(A_times < 0)break; //A_times cannot be negative
if((A*A_times+B*B_times)<N) A_times++;
result = min(result,A*A_times+B*B_times);
//cout << A_times<< " "<< B_times<<" "<< result<<endl;
}
cout << result + A*B*ab_times << endl;
}