結果
問題 |
No.450 ベー君のシャトルラン
|
ユーザー |
![]() |
提出日時 | 2016-12-01 01:51:40 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 952 bytes |
コンパイル時間 | 1,560 ms |
コンパイル使用メモリ | 23,936 KB |
実行使用メモリ | 13,772 KB |
最終ジャッジ日時 | 2024-11-27 14:58:00 |
合計ジャッジ時間 | 10,449 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 17 TLE * 3 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:14:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%lf %lf %lf %lf", &vl, &vr, &d, &w); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <math.h> double px(double a1, double b1, double a2, double b2) { return (b2 - b1) / (a1 - a2); } double py(double a1, double b1, double a2, double b2) { return a1 * px(a1, b1, a2, b2) + b1; } int main() { double vl, vr, d, w; scanf("%lf %lf %lf %lf", &vl, &vr, &d, &w); double x1, y1, x2, y2, x3, y3; double tmp, ans = 0.0, tmpd; int flag = 0; x1 = y1 = 0; x2 = px(1 / w, 0, -(1 / vr), d / vr); y2 = py(1 / w, 0, -(1 / vr), d / vr); do { tmp = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); ans += tmp; if (flag) { x3 = px(-(1 / vr), d / vr, 1 / w, y2 - 1 / w * x2); y3 = py(-(1 / vr), d / vr, 1 / w, y2 - 1 / w * x2); } else { x3 = px(1 / vl, 0, -(1 / w), y2 + 1 / w * x2); y3 = py(1 / vl, 0, -(1 / w), y2 + 1 / w * x2); } x1 = x2; x2 = x3; y1 = y2; y2 = y3; tmpd = x2 - x1 > 0 ? x2 - x1 : x1 - x2; flag = !flag; } while (tmpd > 10e-8); printf("%.7lf\n", ans); return 0; }