Codeforces Round #773 (Div. 2) ABC

Problem - A - Codeforces

题目大意:给定一个三角形的3个坐标,从y=0的这条线上(也就是x轴的这条横线)开始往三角形上画直线,安全的定义是达到三角形的三条边的时候不能有途经灰色区域的部分。问我们不安全的长度是多少?

 input

5
8 10
10 4
6 2
4 6
0 1
4 2
14 1
11 2
13 2
0 0
4 0
2 4
0 1
1 1
0 0

output

0.0000000
0
2.0000
0.00
1

从x轴连一条线上去,什么时侯才会触碰到三角形的阴影区域呢?那就只能是倒着的三角形了(最上面是一条在同一行的直线),特判即可。 

#include<iostream>
#include<cstdio>
#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[200],b[200];
        for(int i=1;i<=3;i++)
            cin>>a[i]>>b[i];
        if(b[1]==b[2]&&b[1]>b[3]) cout<<abs(a[1]-a[2])<<endl;
        else if(b[1]==b[3]&&b[1]>b[2]) cout<<abs(a[1]-a[3])<<endl;
        else if(b[3]==b[2]&&b[3]>b[1]) cout<<abs(a[2]-a[3])<<endl;
        else cout<<"0.000000"<<endl;
    }
    return 0;
}

Problem - B - Codeforces

题目大意:一个小组里有n个孩子,一个孩子的力量相当于这个小组中有多少种不同类型的能量。对于从1到n的每个整数k,找出Sam可以得到的k个孩子组成的团队的最小力量和。

 input

2
3
1 1 2
6
5 1 2 2 2 4

output

2 2 3 
4 4 4 4 5 6 

“一个孩子的力量相当于这个小组中有多少种不同类型的能量 ”种类需要和k进行对比,才能够得出最小力量和。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
int a[20020000];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        map<int,int> mp;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            mp[a[i]]++;
        }
        int flag=mp.size();
        //cout<<flag<<endl;
        for(int i=1;i<=n;i++)
            cout<<max(i,flag)<<" ";
        cout<<endl;
    }
    return 0;
}

Problem - C - Codeforces

题目大意:给定一个长度为n的数组a,让我们给它们凑成成双成对的,条件就是必须要ai*x==aj(ai和aj都存在于数组之中才行),单身狗的话就记起来。问我们记了几个?

input

4
4 4
1 16 4 4
6 2
1 2 2 2 4 7
5 3
5 2 3 5 15
9 10
10 10 10 20 1 100 200 2000 3

output

0
2
3
3

暴力就完了 

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
LL a[20020000];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL t;
    cin>>t;
    while(t--)
    {
        LL n,x;
        cin>>n>>x;
        map<LL,LL> mp;
        for(LL i=1;i<=n;i++)
        {
            cin>>a[i];
            mp[a[i]]++;
        }
        LL sum=0;
        sort(a+1,a+1+n);
        //for(int i=1;i<=n;i++) cout<<a[i]<<" "; cout<<endl;
        for(LL i=1;i<=n;i++)
        {
            if(mp[a[i]]!=0)
            {
                if(mp[a[i]*x]<=0) sum++;
                else mp[a[i]*x]--;
                mp[a[i]]--;
            }
        }
        cout<<sum<<endl;
    }
    return 0;
}

~~~~~~~~~~

开学第一个礼拜课多还布置作业, 这就是大学生吗??溜了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Vijurria

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值