結果

問題 No.450 ベー君のシャトルラン
ユーザー mono1977
提出日時 2016-12-01 03:03:43
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 529 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 23,424 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-11-27 15:02:32
合計ジャッジ時間 6,968 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 TLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%lf %lf %lf %lf",&v1,&v2,&d,&w);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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.0000001){
		if(direction==0){//右向き
			touch=w*d/(w+v2);//蜂が右の車にぶつかるまでの距離
			total+=touch;
			d-=(v1+v2)*d/(w+v2);//左右の車が動いた距離を減らす
			direction=1;
		}else if(direction==1){//左向き
			touch=w*d/(w+v1);
			total+=touch;
			d-=(v1+v2)*d/(w+v1);
			direction=0;
		}
	}
	
	printf("%f\n",total);
	
	return 0;
}
0