zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    爱因斯坦IQ题
    微软操作系统的版本分类方法
    C++的辅助工具介绍
    让Dictionary key 支持自定义对象
    正则表达式匹配可能包括任意长度的任意空白的任意字符串(最短匹配)
    linq 对象转换
    "System.Data.SqlServerCe.SqlCeException: 数据库文件大于配置的最大数据库大小。该设置仅在第一次并发数据库连接后生效"解决方案
    Windows XP远程桌面端口更改
    Unicode与UTF8互转(C语言实现)
    VS2005+WinXPDDK+DDKWizard配置驱动开发环境
  • 原文地址:https://www.cnblogs.com/yyf0309/p/7266703.html
Copyright © 2011-2022 走看看