結果
| 問題 |
No.236 鴛鴦茶
|
| コンテスト | |
| ユーザー |
ty70
|
| 提出日時 | 2015-07-05 22:34:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,504 bytes |
| コンパイル時間 | 642 ms |
| コンパイル使用メモリ | 89,400 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-07 23:14:23 |
| 合計ジャッジ時間 | 1,439 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 WA * 6 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main()
{
ios_base::sync_with_stdio(0);
int a, b, x, y; cin >> a >> b >> x >> y;
int g = __gcd (a, b );
a /= g;
b /= g;
double res = 0.;
// x に合わせる
double y2 = (double)(x/a)*b;
// 範囲内
if (y > y2 + EPS ){
res = max (res, (double)x + y2 );
} // end if
// y に合わせる
double x2 = (double)y/b*a;
// 範囲内
if (x > x2 + EPS ){
res = max (res, x2 + (double)y );
} // end rep
for (int x3 = 1; x3 <= x; x3++ ){
for (int y3 = 1; y3 <= y; y3++ ){
if (b*x3 == a*y3 ){
res = max (res, (double)(x3 + y3 ) );
} // end if
} // end for
} // end for
printf ("%.9lf\n", res );
return 0;
}
ty70