cf427(2) A. Key races

A. Key races

                                    time limit per test1 second
                                 memory limit per test256 megabytes
                                        inputstandard input
                                       outputstandard output
  Two boys decided to compete in text typing on the site "Key races". During the competition, they have to type a text consisting of s characters. The first participant types one character in v1 milliseconds and has ping t1 milliseconds. The second participant types one character in v2 milliseconds and has ping t2 milliseconds.
  If connection ping (delay) is t milliseconds, the competition passes for a participant as follows: 
  1、Exactly after t milliseconds after the start of the competition the participant receives the text to be entered. 
  2、Right after that he starts to type it. 
  3、Exactly t milliseconds after he ends typing all the text, the site receives information about it. 
  The winner is the participant whose information on the success comes earlier. If the information comes from both participants at the same time, it is considered that there is a draw.
  Given the length of the text and the information about participants, determine the result of the game.

Input
  The first line contains five integers s, v1, v2, t1, t2 (1 ≤ s, v1, v2, t1, t2 ≤ 1000) — the number of characters in the text, the time of typing one character for the first participant, the time of typing one character for the the second participant, the ping of the first participant and the ping of the second participant.

Output
  If the first participant wins, print "First". If the second participant wins, print "Second". In case of a draw print "Friendship".

Examples
Input
5 1 2 1 2
Output

Input
3 3 1 1 1
Output
Second

Input
4 5 3 1 5
Output

Note
  In the first example, information on the success of the first participant comes in 7 milliseconds, of the second participant — in 14 milliseconds. So, the first wins.
  In the second example, information on the success of the first participant comes in 11 milliseconds, of the second participant — in 5 milliseconds. So, the second wins.
  In the third example, information on the success of the first participant comes in 22 milliseconds, of the second participant — in 22 milliseconds. So, it is be a draw.

题目大意:有一篇文章,文章有s个字,有两个人打这些字,一个人的速度是每个字需要v1分钟,另一个需要v2分钟,在开始之前和结束之后都需要t时间的延迟,问这两个人谁比赛打字的结果

这个就是一道简单的数学题


import java.util.*;

public class Main{
    public static void main(String arges[]){
        Scanner in = new Scanner(System.in);
        int s, v1, v2, t1, t2;
        s = in.nextInt();
        v1 = in.nextInt();
        v2 = in.nextInt();
        t1 = in.nextInt();
        t2 = in.nextInt();
        int sum1 = s * v1 + 2 * t1;
        int sum2 = s * v2 + 2 * t2;
        if (sum1 < sum2){
            System.out.println("First");
        }
        else if (sum1 > sum2){
            System.out.println("Second");
        }
        else{
            System.out.println("Friendship");
        }
        in.close();
//      return ;
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值