• AtCoder Beginner Contest 053 ABCD题


    A - ABC/ARC


    Time limit : 2sec / Memory limit : 256MB

    Score : 100 points

    Problem Statement

    Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.

    You are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.

    Constraints

    • 1≦x≦3,000
    • x is an integer.

    Input

    The input is given from Standard Input in the following format:

    x
    

    出力

    Print the answer.


    Sample Input 1

    Copy
    1000
    

    Sample Output 1

    Copy
    ABC
    

    Smeke's current rating is less than 1200, thus the output should be ABC.


    Sample Input 2

    Copy
    2000
    

    Sample Output 2

    Copy
    ARC
    

    Smeke's current rating is not less than 1200, thus the output should be ARC.

    题意:1200分作为区分,问打哪一场比赛

    解法:模拟

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin>>n;
        if(n<1200)
        {
            cout<<"ABC";
        }
        else
        {
            cout<<"ARC";
        }
        return 0;
    }

    B - A to Z String


    Time limit : 2sec / Memory limit : 256MB

    Score : 200 points

    Problem Statement

    Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s).

    Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with A and ends with Z.

    Constraints

    • 1≦|s|≦200,000
    • s consists of uppercase English letters.
    • There exists a substring of s that starts with A and ends with Z.

    Input

    The input is given from Standard Input in the following format:

    s
    

    Output

    Print the answer.


    Sample Input 1

    Copy
    QWERTYASDFZXCV
    

    Sample Output 1

    Copy
    5
    

    By taking out the seventh through eleventh characters, it is possible to construct ASDFZ, which starts with A and ends with Z.


    Sample Input 2

    Copy
    ZABCZ
    

    Sample Output 2

    Copy
    4
    

    Sample Input 3

    Copy
    HASFJGHOGAKZZFEGA
    

    Sample Output 3

    Copy
    12
    题意:求从A开始到Z最长的字符串能有多长
    解法:找到最先出现的A,和最后出现的Z,然后就求长度就行
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int st,e;
        string s;
        cin>>s;
        int l=s.length();
        for(int i=0;i<l;i++)
        {
            if(s[i]=='A')
            {
                st=i+1;
                break;
            }
        }
        for(int i=0;i<l;i++)
        {
            if(s[i]=='Z')
            {
                e=i+1;
            }
        }
        cout<<e-st+1<<endl;
        return 0;
    }

    C - X: Yet Another Die Game


    Time limit : 2sec / Memory limit : 256MB

    Score : 300 points

    Problem Statement

    Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.

    Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:

    • Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.

    For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.

    864abc2e4a08c26015ffd007a30aab03.png

    Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

    Constraints

    • 1≦x≦1015
    • x is an integer.

    Input

    The input is given from Standard Input in the following format:

    x
    

    Output

    Print the answer.


    Sample Input 1

    Copy
    7
    

    Sample Output 1

    Copy
    2
    

    Sample Input 2

    Copy
    149696127901
    

    Sample Output 2

    Copy
    27217477801
    题意:

    给你一个色子,初始的时候任意一个面朝上,每次操作可以将色子翻一下,并且得到此时面朝上的点数并相加,

    问你想要得到至少X分,最少需要多少次操作。

    解法:我们两次能得到的最大点之和11,10,9,8,7,小于7的我们翻一次就行

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 #define ll long long
     4 int main()
     5 {
     6     ll n;
     7     cin>>n;
     8     ll sum=0;
     9     sum+=2*(n/11);
    10     n%=11;
    11     sum+=2*(n/10);
    12     n%=10;
    13     sum+=2*(n/9);
    14     n%=9;
    15     sum+=2*(n/8);
    16     n%=8;
    17     sum+=2*(n/7);
    18     n%=7;
    19     if(n==0)
    20     {
    21     cout<<sum<<endl;
    22     }
    23     else
    24     {
    25         cout<<sum+1<<endl;
    26     }
    27     return 0;
    28 }

    D - Card Eater


    Time limit : 2sec / Memory limit : 256MB

    Score : 400 points

    Problem Statement

    Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer Ai is written.

    He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.

    Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.

    Constraints

    • 3≦N≦105
    • N is odd.
    • 1≦Ai≦105
    • Ai is an integer.

    Input

    The input is given from Standard Input in the following format:

    N
    A1 A2 A3 ... AN
    

    Output

    Print the answer.


    Sample Input 1

    Copy
    5
    1 2 1 3 7
    

    Sample Output 1

    Copy
    3
    

    One optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 13 and 7.


    Sample Input 2

    Copy
    15
    1 3 5 2 1 3 2 8 8 6 2 6 11 1 1
    

    Sample Output 2

    Copy
    7
    

    题意:我们每次选择三张牌,去掉最大最小牌,留下一张放回,问最后能留下多少种唯一的牌

    解法:每次我们是减去两张,题目给了奇数个,那么留下总数的必定是奇数,我们去重之后看能够得到多少种,偶数种再减去一,奇数保留。

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int main()
     4 {
     5     int n;
     6     int a[200000];
     7     cin>>n;
     8     for(int i=0;i<n;i++)
     9     {
    10         cin>>a[i];
    11     }
    12     sort(a,a+n);
    13     int x=unique(a,a+n)-a;
    14     if(x%2)
    15     {
    16         cout<<x;
    17     }
    18     else
    19     {
    20         cout<<x-1;
    21     }
    22     return 0;
    23 }
    
    
  • 相关阅读:
    Windows 网络监测ping IP输出时间
    python
    遇见问题汇总
    在路上积累
    Condition
    ReentrantReadWriteLock
    AbstractQueuedSynchronizer
    jmeter使用
    使用VisualVM监控java进程
    CNVD漏洞证书(2)
  • 原文地址:https://www.cnblogs.com/yinghualuowu/p/6395310.html
Copyright © 2020-2023  润新知