結果

問題 No.450 ベー君のシャトルラン
コンテスト
ユーザー mono1977
提出日時 2016-12-01 03:07:10
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 661 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 179 ms
コンパイル使用メモリ 38,400 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2026-05-21 21:25:03
合計ジャッジ時間 4,289 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 TLE * 1 -- * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>

int main(){
	double v1,v2,d,w;
	scanf("%lf %lf %lf %lf",&v1,&v2,&d,&w);
	
	double total=0;
	double touch=0;
	int direction=0;
	
	while(d>0.000001){
		if(direction==0){//右向き
			touch=w*d/(w+v2);//蜂が右の車にぶつかるまでの距離
//			printf("%lf\n",touch);
			total+=touch;
			d-=(v1+v2)*d/(w+v2);//左右の車が動いた距離を減らす
//			printf("total=%lf nokori=%lf\n",total,d);
			direction=1;
		}else{//左向き
			touch=w*d/(w+v1);
//			printf("%lf\n",touch);
			total+=touch;
			d-=(v1+v2)*d/(w+v1);
//			printf("total=%lf nokori=%lf\n",total,d);
			direction=0;
		}
	}
	
	printf("%f\n",total);
	
	return 0;
}
0