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

    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(1≤i≤2,1≤j≤3) 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

    Copy
    pot
    top
    

    Sample Output 1

    Copy
    YES
    

    This grid remains the same when rotated 180 degrees.


    Sample Input 2

    Copy
    tab
    bet
    

    Sample Output 2

    Copy
    NO
    

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


    Sample Input 3

    Copy
    eye
    eel
    

    Sample Output 3

    Copy
    NO
    
    #include<bits/stdc++.h>
     
    #define _ cin.tie(0);ios::sync_with_stdio(false);
    using namespace std;
     
    int main(){ _
     
     
     
        string str, tmp;
        while(cin >> str >> tmp){
        reverse(str.begin(), str.end());
        if(str == tmp) cout << "YES" << endl;
        else cout << "NO" << endl;
        }
    }

    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

    • 1≤N≤109
    • 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

    Copy
    10
    

    Sample Output 1

    Copy
    9
    

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


    Sample Input 2

    Copy
    81
    

    Sample Output 2

    Copy
    81
    

    Sample Input 3

    Copy
    271828182
    

    Sample Output 3

    Copy
    271821169
    #include<bits/stdc++.h>
     
    #define _ cin.tie(0);ios::sync_with_stdio(false);
    using namespace std;
    using LL = long long;
    int main(){ _
        LL n, m;
        while(cin >> n){
            for(LL i = 1; i*i <= n; i++) m = i * i;
            cout << m << endl;
    
    /*
    int i = sqrt(n);
    cout << i * i << endl;
    */
        }      
    }

    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

    • 1≤N≤105
    • 1≤Ai≤109(1≤iN)
    • 1≤Bi≤109(1≤iN)
    • 1≤Ci≤109(1≤iN)
    • 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

    Copy
    2
    1 5
    2 4
    3 6
    

    Sample Output 1

    Copy
    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

    Copy
    3
    1 1 1
    2 2 2
    3 3 3
    

    Sample Output 2

    Copy
    27
    

    Sample Input 3

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

    Sample Output 3

    Copy
    87
    #include<bits/stdc++.h>
    
    #define _ cin.tie(0);ios::sync_with_stdio(false);
    using namespace std;
    
    #define rep(n) for(int i = 0; i < n; i++)
    #define Sort(a) sort(a.begin(), a.end())
    using LL = long long;
    const int N = 100000 + 5;
    
    LL tree[N];
    LL Query(int pos){
        LL sum = 0;
        while(pos > 0){
            sum += tree[pos];
            pos -= (pos & -pos);
        }
        return sum;
    }
    
    void Add(int pos,LL num){
        while(pos <= N){
            tree[pos] += num;
            pos += (pos & -pos);
        }
    }
    vector<LL> a, b, c;
    int main(){ _
        LL  n, m;
        memset(tree, 0, sizeof(tree));
        cin >> n;
        rep(n) { cin >> m; a.push_back(m); }
        rep(n) { cin >> m; b.push_back(m); }
        rep(n) { cin >> m; c.push_back(m); }
        Sort(a), Sort(b), Sort(c);
    
        for(int i = 0; i < n; i++){
            auto tmp = lower_bound(a.begin(), a.end(), b[i]);
            int num = tmp - a.begin();
            Add(i + 1, num);
    
        }
        LL sum = 0;
        for(auto &i : c){
            auto tmp = lower_bound(b.begin(), b.end(), i);
            int cur = tmp - b.begin();
            LL num = Query(cur);
            sum += num;
        }
        /**
        LL sum = 0;
        rep(n){
            LL A = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
            LL B = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
            sum += (A * B);
        }*/
        cout << sum << endl;
    }

      

  • 相关阅读:
    敏捷开发系列学习总结(5)——这几招搞定团队协同Coding
    敏捷开发系列学习总结(4)—Git管理工具sourcetree的安装
    Java基础学习总结(74)——Java常见笔试题及答案汇总
    iOS 极光推送
    iOS UI控件没有显示时的调试技巧
    iOS 搜索之拼音搜索
    iOS MJExtension框架之字典数组转模型数组
    iOS 单例
    iOS 切换键盘
    iOS 正则表达式
  • 原文地址:https://www.cnblogs.com/Pretty9/p/7784838.html
Copyright © 2011-2022 走看看