• Codeforces Round #427 (Div. 2) Problem A Key races (Codeforces 835 A)


    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
    First
    Input
    3 3 1 1 1
    Output
    Second
    Input
    4 5 3 1 5
    Output
    Friendship
    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.


      题目大意 两个人开始打字游戏,每个人有一个速度,以及发送打字的文本串和提交文本串会有一个延时。问谁会赢。

      按照题目意思,算出运营商收到两人的提交文本最少要耗的时间。

    Code

     1 /**
     2  * Codeforces
     3  * Problem#835A
     4  * Accepted
     5  * Time:30ms
     6  * Memory:2100k
     7  */ 
     8 #include <bits/stdc++.h> 
     9 #ifndef WIN32
    10 #define Auto "%lld"
    11 #else
    12 #define Auto "%I64d"
    13 #endif
    14 using namespace std;
    15 typedef bool boolean;
    16 const signed int inf = (signed)((1u << 31) - 1);
    17 const signed long long llf = (signed long long)((1ull << 61) - 1);
    18 const double eps = 1e-6;
    19 const int binary_limit = 128;
    20 #define smin(a, b) a = min(a, b)
    21 #define smax(a, b) a = max(a, b)
    22 #define max3(a, b, c) max(a, max(b, c))
    23 #define min3(a, b, c) min(a, min(b, c))
    24 template<typename T>
    25 inline boolean readInteger(T& u){
    26     char x;
    27     int aFlag = 1;
    28     while(!isdigit((x = getchar())) && x != '-' && x != -1);
    29     if(x == -1) {
    30         ungetc(x, stdin);    
    31         return false;
    32     }
    33     if(x == '-'){
    34         x = getchar();
    35         aFlag = -1;
    36     }
    37     for(u = x - '0'; isdigit((x = getchar())); u = (u << 1) + (u << 3) + x - '0');
    38     ungetc(x, stdin);
    39     u *= aFlag;
    40     return true;
    41 }
    42 
    43 int s, v0, v1, t0, t1;
    44 
    45 inline void init() {
    46     scanf("%d%d%d%d%d", &s, &v0, &v1, &t0, &t1);
    47 }
    48 
    49 inline void solve() {
    50     int a = 2 * t0 + s * v0;
    51     int b = 2 * t1 + s * v1;
    52     if(a > b)
    53         puts("Second");
    54     else if(a < b)
    55         puts("First");
    56     else
    57         puts("Friendship");
    58 }
    59 
    60 int main() {
    61     init();
    62     solve();
    63     return 0;
    64 }
  • 相关阅读:
    Tomcat 8.5 添加https认证
    常用服务的搭建、配置及优化
    Linux基础知识整理
    在CentOS-6系统中二进制安装MySQL-5.6
    搭建本地yum源仓库
    Redis-请慎用String类型
    Redis AOF日志备份原理
    MySQL 输入查询
    MySQL 命令行连接选项
    感思-最好的优化就是减少数据量!
  • 原文地址:https://www.cnblogs.com/yyf0309/p/7266703.html
Copyright © 2020-2023  润新知