zoukankan      html  css  js  c++  java
  • Codeforces Round #427 (Div. 2)

    Problem A

    A. Key races
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard 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 scharacters. 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 sv1, 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 14milliseconds. 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 5milliseconds. 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 22milliseconds. So, it is be a draw.

     水题.

     1 #include<iostream>
     2 #include<stdio.h>
     3 using namespace std;
     4 int main(){
     5     int s;
     6     int v1,v2,t1,t2;
     7     cin>>s>>v1>>v2>>t1>>t2;
     8     int s1=s*v1+2*t1;
     9     int s2=s*v2+2*t2;
    10     if(s1==s2){
    11         cout<<"Friendship"<<endl;
    12     }else if(s1>s2){
    13         cout<<"Second"<<endl;
    14     }else{
    15         cout<<"First"<<endl;
    16     }
    17     return 0;
    18 }

    problem  B

    B. The number on the board
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Some natural number was written on the board. Its sum of digits was not less than k. But you were distracted a bit, and someone changed this number to n, replacing some digits with others. It's known that the length of the number didn't change.

    You have to find the minimum number of digits in which these two numbers can differ.

    Input

    The first line contains integer k (1 ≤ k ≤ 109).

    The second line contains integer n (1 ≤ n < 10100000).

    There are no leading zeros in n. It's guaranteed that this situation is possible.

    Output

    Print the minimum number of digits in which the initial number and n can differ.

    Examples
    input
    3
    11
    output
    1
    input
    3
    99
    output
    0
    Note

    In the first example, the initial number could be 12.

    In the second example the sum of the digits of n is not less than k. The initial number could be equal to n.

     题意:找出一个数字它的每个位数的和大于等于K,并且与n的不同的位数最小。

     1 #include<iostream>
     2 #include<stdio.h>
     3 #include<string.h>
     4 #include<algorithm>
     5 using namespace std;
     6 char a[100010];
     7 int cha[11];
     8 int main(){
     9     int k;
    10     cin>>k;
    11     scanf("%s",&a);
    12     memset(cha,0,sizeof(cha));
    13     int len=strlen(a),sum=0;
    14     for(int i=len-1;i>=0;i--){
    15         int xx=a[i]-'0';
    16         sum+=xx;
    17         cha[xx]++;
    18     }
    19     if(sum>=k){
    20         cout<<0<<endl;
    21     }else{
    22         int num=0;
    23         bool flag=false;
    24         for(int i=0;i<9;i++){
    25             for(int j=cha[i];j>0;j--){
    26                 sum+=(9-i);
    27                 num++;
    28                 if(sum>=k){
    29                     flag=true;
    30                     break;
    31                 }
    32             }
    33             if(flag)    break;
    34         }
    35         cout<<num<<endl;
    36     }
    37 }
  • 相关阅读:
    作为一名程序员这些代码托管工具你都知道吗?
    QA小课堂:一个网站或者APP开发要多少钱
    成为优秀程序员必备的七点
    成为一个优秀程序员的11条小贴士
    如何成为优秀的程序员?
    互联网自由工作者必须要知道的七点
    为什么程序员会是特立独行的存在?
    互联网时代程序员如何避免知识半衰期?
    万众创新:你是一个优秀的程序员吗?
    如何提高程序员10倍的生产力
  • 原文地址:https://www.cnblogs.com/ISGuXing/p/7270653.html
Copyright © 2011-2022 走看看