zoukankan      html  css  js  c++  java
  • AtCoder Beginner Contest 077(ABC)

    A - Rotation


    Time limit : 2sec / Memory limit : 256MB

    Score : 100 points

    Problem Statement

    You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character Cij.

    Write a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise.

    Constraints

    • Ci,j(1i2,1j3) is a lowercase English letter.

    Input

    Input is given from Standard Input in the following format:

    C11C12C13
    C21C22C23
    

    Output

    Print YES if this grid remains the same when rotated 180 degrees; print NO otherwise.


    Sample Input 1

    pot
    top
    

    Sample Output 1

    YES
    

    This grid remains the same when rotated 180 degrees.


    Sample Input 2

    tab
    bet
    

    Sample Output 2

    NO
    

    This grid does not remain the same when rotated 180 degrees.


    Sample Input 3

    eye
    eel
    

    Sample Output 3

    NO


     1     #include <iostream>
     2     #include <cstring>
     3     #include <cstdio>
     4     #include <algorithm>
     5      
     6     using namespace std;
     7     string s,s1;
     8     int main(){
     9         cin>>s>>s1;
    10         bool prime=true;
    11         int slen=s.length();
    12         int sslen=s1.length();
    13         for(int i=0,j=sslen-1;i<slen&&j>=0;i++,j--){
    14             if(s[i]!=s1[j])
    15                 {
    16                     prime=false;
    17                     break;
    18                 }
    19         }
    20         if(prime)
    21             cout<<"YES"<<endl;
    22         else
    23             cout<<"NO"<<endl;
    24         return 0;
    25     }

    B - Around Square


    Time limit : 2sec / Memory limit : 256MB

    Score : 200 points

    Problem Statement

    Find the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer.

    Constraints

    • 1N109
    • N is an integer.

    Input

    Input is given from Standard Input in the following format:

    N
    

    Output

    Print the largest square number not exceeding N.


    Sample Input 1

    10
    

    Sample Output 1

    9
    

    10 is not square, but 9=3×3 is. Thus, we print 9.


    Sample Input 2

    81
    

    Sample Output 2

    81
    

    Sample Input 3

    271828182
    

    Sample Output 3

    271821169


     1     #include <iostream>
     2     #include <cmath>
     3     #include <cstring>
     4     #include <cstdio>
     5      
     6     using namespace std;
     7     int n;
     8     int main(){
     9         while(cin>>n){
    10             int a=sqrt(n);
    11             cout<<a*a<<endl;
    12         }
    13         return 0;
    14     }

    C - Snuke Festival


    Time limit : 2sec / Memory limit : 256MB

    Score : 300 points

    Problem Statement

    The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.

    He has N parts for each of the three categories. The size of the i-th upper part is Ai, the size of the i-th middle part is Bi, and the size of the i-th lower part is Ci.

    To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.

    How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.

    Constraints

    • 1N105
    • 1Ai109(1iN)
    • 1Bi109(1iN)
    • 1Ci109(1iN)
    • All input values are integers.

    Input

    Input is given from Standard Input in the following format:

    N
    A1  AN
    B1  BN
    C1  CN
    

    Output

    Print the number of different altars that Ringo can build.


    Sample Input 1

    2
    1 5
    2 4
    3 6
    

    Sample Output 1

    3
    

    The following three altars can be built:

    • Upper: 1-st part, Middle: 1-st part, Lower: 1-st part
    • Upper: 1-st part, Middle: 1-st part, Lower: 2-nd part
    • Upper: 1-st part, Middle: 2-nd part, Lower: 2-nd part

    Sample Input 2

    3
    1 1 1
    2 2 2
    3 3 3
    

    Sample Output 2

    27
    

    Sample Input 3

    6
    3 14 159 2 6 53
    58 9 79 323 84 6
    2643 383 2 79 50 288
    

    Sample Output 3

    87


     1     #include <iostream>
     2     #include <cstring>
     3     #include <cstdio>
     4     #include <algorithm>
     5     #include <vector>
     6     #define ll long long int
     7     #define N 100005
     8     using namespace std;
     9     vector<int> k[3];
    10     ll dp[3][N];
    11     int main(){
    12         int n;
    13         cin>>n;
    14         for(int i=0;i<3;i++){
    15             for(int j=0;j<n;j++){
    16                 int x;
    17                 cin>>x;
    18                 k[i].push_back(x);
    19             }
    20             sort(k[i].begin(),k[i].end());
    21         }
    22         dp[0][0]=1;
    23         for(int i=1;i<n;i++)
    24             dp[0][i]=dp[0][i-1]+1;
    25      
    26         for(int i=1;i<3;i++){
    27             for(int j=0;j<n;j++){
    28                 int x=lower_bound(k[i-1].begin(),k[i-1].end(),k[i][j])-k[i-1].begin();
    29                 dp[i][j]+=dp[i-1][x-1];
    30             }
    31             for(int t=1;t<n;t++)
    32                 dp[i][t]+=dp[i][t-1];
    33         }
    34         cout<<dp[2][n-1]<<endl;
    35         return 0;
    36     }
  • 相关阅读:
    [POI2014]KUR-Couriers
    MySQL有哪些索引
    索引的设计原则
    explain参数之extra
    explain参数之type
    explain参数之select_type
    如何查询最后一行的记录
    为什么MySQL自增id不连续?
    MySQL字符集
    MySQL有哪些优化策略?
  • 原文地址:https://www.cnblogs.com/zllwxm123/p/7799320.html
Copyright © 2011-2022 走看看