結果

問題 No.450 ベー君のシャトルラン
ユーザー kurenai3110
提出日時 2016-12-01 00:27:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 477 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 67,008 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-27 14:35:51
合計ジャッジ時間 1,175 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
using namespace std;

int main()
{
	double vl, vr, d, w; cin >> vl >> vr >> d >> w;

	double dist = 0;

	double l = 0, r = d;
	int limit = 0;
	while (l < r && limit<10000) {
		double cnt;
		if (w > 0) cnt = (r - l) / (w + vr);
		else cnt = (r - l) / (vl - w);
		dist += cnt*abs(w);
		l += cnt*vl;
		r -= cnt*vr;
		w = -w;
		limit++;
	}

	cout << fixed << setprecision(8) << dist << endl;

	return 0;
}
0