FZU 1889 龟兔赛跑

Problem Description

万众瞩目的第七届龟兔赛跑比赛在北京时间3333年3月3日于火星打响。此次龟兔赛跑比赛的规则与往届有所不同,不再考察兔子和乌龟谁在最短的时间内跑完规定的路程,而是考察谁在规定时间内跑的路程最长,而且兔子和乌龟在跑步都是匀速的。由于兔子的坏习惯,它总是喜欢把比赛的总时间T小时中的K小时拿来睡觉。现在给你比赛总时间T、兔子睡觉时间K、兔子的时速U、乌龟的时速V,需要你求出该次比赛谁最后获胜。

Input

输入数组第一行为一个数X,表示有X组输入数据。每组数据只有一行,包括4个数T(1 <= T <= 300), K(0 <= K <= T), U(1 <= U <= 100), V(1 <= V <= 100)。

Output

对于每组数据,输出只有一个整数,如果兔子获胜,则输出0,如果乌龟获胜则输出1,如果同时到达,则输出-1。

Sample Input

2

1 1 1 1

6 3 6 3

Sample Output

1

-1

Source

福州大学第七届程序设计竞赛

时间: 2024-11-05 12:25:03

FZU 1889 龟兔赛跑的相关文章

FZU 2150 Fire Game(点火游戏)

p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-size: 10.5000pt } h2 { margin-top: 5.0000pt; margin-bottom: 5.0000pt; text-align: left; font-family: 宋体; font-weight: bold; font-size: 18.0000pt } h3 {

FZU 1096 QS Network

QS Network Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 1096 64-bit integer IO format: %I64d      Java class name: Main In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS.

Java并发编程:Callable、Future和FutureTask 实现龟兔赛跑

1.不清楚的看博客http://www.cnblogs.com/dolphin0520/p/3949310.html 我们使用上面的代码来实现一个龟兔赛跑 package com.weiyuan.test; import java.util.concurrent.Callable; import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurre

FZU 1759 欧拉函数 降幂公式

Description Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000). Input There are multiply testcases. Each testcase, there is one line contains three integers A, B and C, separated by a singl

ACM: FZU 2150 Fire Game - DFS+BFS+枝剪 或者 纯BFS+枝剪

FZU 2150 Fire Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description Fat brother and Maze are playing a kind of special (hentai) game on an N*M board (N rows, M columns). At the beginning, each grid of this boar

FZU 2112 并查集、欧拉通路

原题:http://acm.fzu.edu.cn/problem.php?pid=2112 首先是,票上没有提到的点是不需要去的. 然后我们先考虑这个图有几个联通分量,我们可以用一个并查集来维护,假设有n个联通分量,我们就需要n-1条边把他们连起来. 最后对于每个联通分量来说,我们要使它能一次走完,就是要求他是否满足欧拉通路,也就是这个联通分量中至多有2个度为奇数的点,每多出2个度为奇数的点,就多需要一条边(因为单个连通分量的所有点的度数之和为偶数,所以不可能存在奇数个奇数度数的点). 1 #i

FZU Problem 2102 Solve equation (数学啊 )

题目链接:http://acm.fzu.edu.cn/problem.php?pid=2102 Problem Description You are given two positive integers A and B in Base C. For the equation: A=k*B+d We know there always existing many non-negative pairs (k, d) that satisfy the equation above. Now in

FZU Problem 2104 Floor problem (数学啊 )

题目链接:http://acm.fzu.edu.cn/problem.php?pid=2104 Problem Description In this problem, we have f(n,x)=Floor[n/x]. Here Floor[x] is the biggest integer such that no larger than x. For example, Floor[1.1]=Floor[1.9]=1, Floor[2.0]=2. You are given 3 posit

*循环-18. 龟兔赛跑

1 /* 2 * Main.c 3 * C18-循环-18. 龟兔赛跑 4 * Created on: 2014年8月4日 5 * Author: Boomkeeper 6 ******部分通过******* 7 */ 8 9 #include <stdio.h> 10 #include <stdlib.h> 11 12 int t = 0; 13 int distanceR = 0, distanceT = 0; 14 //int *pdistanceR = &dista