Codeforces Round #755 (Div. 2, based on Technocup 2022 Elimination Round 2) ABC

2021/11/16 23:39:56

本文主要是介绍Codeforces Round #755 (Div. 2, based on Technocup 2022 Elimination Round 2) ABC,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Problem - A - Codeforces

题目大意:给定u,v,求x,y。要满足x/u + y/v =( x+y)  / (u+v)

input

4
1 1
2 3
3 5
6 9

output

-1 1
-4 9
-18 50
-4 9

u*u *y=-x *v*v    so y=-x*v*v/u*u   开longlong即可

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        long long int u,v;
        cin>>u>>v;
        if(u==v) cout<<"-1 1"<<endl;
        else
        {
            long long int x=u*u;
            long long int y=-v*v;
            cout<<x<<" "<<y<<endl;
        }
    }
    return 0;
}

Problem - B - Codeforces

题目大意:n*m的红色矩形,除1*1外可任意裁剪。为了让相邻的任意一对单元格(来自同一片断)具有不同的颜色。
问至少要画多少个单元格?

input

4
1 3
2 2
2 5
3 5

output

1
2
4
5

切入点就是3格划分为最小,划完3格的,余下2格的再划一格

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        int flag;
        if(a>b) { flag=a; a=b; b=flag; }
        if(a%3==0) cout<<b*(a/3)<<endl;
        else if(b%3==0) cout<<a*(b/3)<<endl;
        else cout<<a/3*b+(a%3==1?b/3+(b%3>0?1:0):b/3*2+b%3)<<endl;
    }
    return 0;
}

Problem - C - Codeforces

题目大意:a数组能否经历+1或不动变为b数组。可以为“YES”,反之“NO”。

input

3
3
-1 1 0
0 0 2
1
0
2
5
1 2 3 4 5
1 2 3 4 5

output

YES
NO
YES
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[200200],b[200200];
        for(int i=1;i<=n;i++)
            cin>>a[i];
        for(int i=1;i<=n;i++)
            cin>>b[i];
        sort(a+1,a+1+n);
        sort(b+1,b+1+n);
        bool flag=true;
        for(int i=1;i<=n;i++)
            if(b[i]-a[i]==1||b[i]==a[i]) continue;
            else { flag=false; break; }
        if(flag==false) cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }
    return 0;
}

嘎嘎冲! 



这篇关于Codeforces Round #755 (Div. 2, based on Technocup 2022 Elimination Round 2) ABC的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程