結果

問題 No.450 ベー君のシャトルラン
ユーザー kurenai3110kurenai3110
提出日時 2016-12-01 00:25:57
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 475 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 66,172 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 14:35:33
合計ジャッジ時間 1,145 ms
ジャッジサーバーID
(参考情報)
judge4 / 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<100) {
		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