UVA 10773 Back to Intermediate Math(数论)

来源:互联网 发布:中国移动网络加速器 编辑:程序博客网 时间:2024/06/07 01:42

题目链接:Back to Intermediate Math

题意:两种过河方式,一种笔直过河,一种最快过河,求两种时间差

只要计算出两种时间,笔直过河的速度等于两个速度分量的合速度,最快就等于船速度,求出差即可。

代码:

#include <stdio.h>#include <string.h>#include <math.h>int t, d, v, u;int main() {int cas = 0;scanf("%d", &t);while (t--) {scanf("%d%d%d", &d, &v, &u);printf("Case %d: ", ++cas);if (u == 0 || v == 0 || v >= u) printf("can't determine\n");else {double t1 = d * 1.0 / u;double t2 = d * 1.0 / sqrt(u * u - v * v);printf("%.3lf\n", fabs(t1 - t2));}}return 0;}


1 0
原创粉丝点击