UVA 10773 Back to Intermediate Math(数论)

题目链接: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;
}

UVA 10773 Back to Intermediate Math(数论),码迷,mamicode.com

时间: 2024-12-08 00:57:40

UVA 10773 Back to Intermediate Math(数论)的相关文章

uva 10773 - Back to Intermediate Math(数论)

题目链接:uva 10773 - Back to Intermediate Math 题目大意:有一天河,宽d,水流速度v,船速u,问说垂直过河和最快过河的时间差,如果不能过河输出"can't determine". 解题思路:将u的速度分解成水平方向和竖直方向的两个速度,使水平方向速度恰好为v,船即可垂直过河,速度为竖直方向速度. #include <cstdio> #include <cstring> #include <cmath> const

UVa 10773 - Back to Intermediate Math

题目:渡河问题.给你河水宽度,水流速度,求垂直渡河与最快渡河的时间差. 分析:物理题,数学题. 最快渡河情况,传垂直运动,垂直渡河,船的水平分速度和水流速度抵消. 说明:注意水流速度不能为0. #include <cstdio> #include <cmath> int main() { int T; scanf("%d",&T); for (int t = 1 ; t <= T ; ++ t) { double d,v,u; scanf(&quo

UVA 10548 - Find the Right Changes(数论)

UVA 10548 - Find the Right Changes 题目链接 题意:给定a,b,c,表示货物的价值,求由A货物和B货物组成C货物有几种方法,判断有无解和是否有无限多种 思路:扩展欧几里得求通解,去计算上限和下限就能判断 代码: #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> using namespace std; const long l

UVA 10791 Minimum Sum LCM (数论)

LCM (Least Common Multiple) of a set of integers is defined as the minimum number, which is a multiple of all integers of that set. It is interesting to note that any positive integer can be expressed as the LCM of a set of positive integers. For exa

UVA 10375 Choose and divide(数论)

The binomial coefficient C(m,n) is defined as m! C(m,n) = -------- n!(m-n)! Given four natural numbers p, q, r, and s, compute the the result of dividing C(p,q) by C(r,s). The Input Input consists of a sequence of lines. Each line contains four non-n

UVA 11246 - K-Multiple Free set(数论推理)

UVA 11246 - K-Multiple Free set 题目链接 题意:一个{1..n}的集合,求一个子集合,使得元素个数最多,并且不存在有两个元素x1 * k = x2,求出最多的元素个数是多少 思路:推理一下, 一开始n个 先要删除k倍的,删除为{k, 2k, 3k, 4k, 5k, 6k...},会删掉多余的k^2,因此在加回k^2倍的数 然后现在集合中会出现情况的只有k^2的倍数,因此对k^2倍的数字看成一个新集合反复做这个操作即可,因此最后答案为n - n / k + n /

uva 12119 - The Bells are Ringing(数论+枚举)

题目链接:uva 12119 - The Bells are Ringing 题目大意:有三个钟,分别间隔t1,t2,t3秒响一次,0时刻同时响,给定M,问有没又满足的三个数,最小公倍数为M.并且t3-t1<=25 解题思路:因为M为t1,t2,t3的最小公倍数,所以ti一定为M的因子,所以只要枚举因子判断即可. #include <cstdio> #include <cstring> #include <algorithm> using namespace st

UVa 106 - Fermat vs Pythagoras(数论题目)

题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=42  Fermat vs. Pythagoras  Background Computer generated and assisted proofs and verification occupy a small niche in the realm

UVA - 10791 - Minimum Sum LCM (数论相关!)

题目链接:Minimum Sum LCM UVA - 10791 Minimum Sum LCM Time Limit:3000MS   Memory Limit:Unknown   64bit IO Format:%lld & %llu SubmitStatus Description  Minimum Sum LCM  LCM (Least Common Multiple) of a set of integers is defined as the minimum number, whic