题目大意:给定一个三角形的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 0output
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;
}
题目大意:一个小组里有n个孩子,一个孩子的力量相当于这个小组中有多少种不同类型的能量。对于从1到n的每个整数k,找出Sam可以得到的k个孩子组成的团队的最小力量和。
input
2 3 1 1 2 6 5 1 2 2 2 4output
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;
}
题目大意:给定一个长度为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 3output
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;
}
~~~~~~~~~~
开学第一个礼拜课多还布置作业, 这就是大学生吗??溜了