Educational Codeforces Round 118 (Rated for Div. 2)

A :Long Comparison

题目就是给你 2个数字  每一个数字后面跟着多少个零 比较大小

思路就是直接用字符串比较

#include "bits/stdc++.h"
using namespace std;
int t;
int a,b,q,w;
int main()
{
    cin >> t;
    while (t--){
        cin >> a >> q;
        cin >> b >> w;
        while (a){
            int x = a%10;
            if(x!=0) break;
            else q++;
            a/=10;
        }
        while (b){
            int x = b%10;
            if(x!=0) break;
            else w++;
            b/=10;
        }
        string x= to_string(a) , y = to_string(b);
        int len = x.size() + q , len1 = y.size() + w;
        if(len == len1){
            if(x > y) cout << '>' << endl;
            else if(x == y) cout << '=' << endl;
            else cout << '<' << endl;
        }else if(len > len1) cout << '>' << endl;
        else cout << '<' << endl;


    }

    return 0;
}

B :Absent Remainder

题目给你t组样例 每一组用不同的元素取模 取出你这一没有的元素 ,那么这俩个不同数字成立,思路就是用最大数取最小数 ,那么取模出来的数字肯定比你数组中的数字还要小

#include "bits/stdc++.h"

using namespace std;
const int N = 2e5+5;
int t,n;
int s[N];
int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n;
        for(int i=1;i<=n;i++){
            cin >> s[i];
        }
        sort(s+1,s+1+n);
        set>se;
        for(int i=n;i>=2;i--){
            se.insert({s[i],s[1]});
            if(se.size() == n/2) break;
        }
        for(auto i : se){
            cout << i.first << " " << i.second << endl;
        }
    }

    return 0;
}

C:Poisoned Dagger

t组样例,给你n和h , n里面的每一个数字是什么时候必须打恶龙,而h是恶龙的生命

让你用最小的固定伤害杀死恶龙,每一秒恶龙只能掉一滴血,然后重新使用毒药会重置毒药时间

解题思路:二分搜索        由于第i次攻击的毒药对i

#include "bits/stdc++.h"
#define ll long long
using namespace std;
int t,n;
ll s[105];
ll h,l,r;
int main()
{
    cin >> t;
    while (t--)
    {
        cin >>  n >> h;
        for(int i=1 ;i<=n;i++) cin >> s[i];
        l = 1 , r=1e18;
        while (l<=r)
        {
            ll mid = (l+r)>>1;
            ll sum = mid;
            for(int i=1 ; i

你可能感兴趣的:(codeforces,c++)