AtCoder Beginner Contest 205

A

没有一百毫升有A卡路里,B毫升中有多少卡路里

#include <bits/stdc++.h>
using namespace std;


int main()
{
    double a , b;
    cin >> a >> b;
    cout << a * b / 100 << endl;
    return 0;
}

B

长度为\(N\)的数列是否由\([1,N]\)构成,且不重复

#include<bits/stdc++.h>
using namespace std;


int main()
{
    set<int> s;
    int n;
    cin >> n;
    for( int i = 1 , x ; i <= n ; i ++ ) cin >> x , s.insert(x);
    if( *s.begin() == 1 && s.size() == n ) cout << "Yes\n";
    else cout << "No\n";
}

C

判断\(A^C\)\(B^C\)的大小关系

#include <bits/stdc++.h>
using namespace std;


int main()
{
    int a , b , c;
    cin >> a >> b >> c;
    if( c == 0 || a == b || ( a + b == 0 && c % 2 == 0 ) ) cout << "=\n";
    else if( c & 1 ) cout <<  (  ( a > b ) ? ">\n" : "<\n" );
    else cout << ( ( abs(a) > abs(b) ) ? ">\n" : "<\n" );
    return 0;
}

D

\([1,+\infty)\)中不在\(A_1\cdots A_N\)中的第\(k\)大数是多少?

#include <bits/stdc++.h>
using namespace std;


int main()
{
    long long n , q , a[ 100005 ];
    cin >> n >> q;
    for( int i = 0 ; i < n ; i ++ )
    {
        cin >> a[i];
        a[i] -= i;
     }
     for( long long i = 1 , x ; i <= q ; i ++ )
     {
         cin >> x;
         cout << x + ( upper_bound( a , a + n , x ) - a ) << endl;
     }

    return 0;
}
posted @ 2021-11-15 19:09  PHarr  阅读(91)  评论(0编辑  收藏  举报