qbxt Day 7

Day 7

考试题解

T1 water

最后一天的签到题太水了,真的是有手就行。考试时5min就切了。

主要到数值大小范围在1e6以内,考虑开桶维护,直接排序模拟即可。

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int n,k,tot,ans,maxx;
int a[2000005],f[2000005];
int main()
{
	n=read();k=read();
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(f[a[i]]==0) tot++;
		f[a[i]]++;
		maxx=max(maxx,a[i]);
	}
	sort(f+1,f+1+maxx);
	for(int i=1;i<=maxx;i++){
		if(tot<=k) break;
		if(f[i]!=0){
			tot--;
			ans+=f[i];
		}
	}
	printf("%d
",ans);
	return 0;
}

T2 circle

不会证明,没听懂???

T3 path

斯特兰数:设有(n)个球放进(m)个盒子里,不能有空盒子,方案数是(S_{n,m})。那么我们取出一个球,如果取出之后这个盒子空了,那么方案数应该加上(S_{n-1,m-1}),如果没空,那么方案数应该加上(S_{n-1,m})

推式子

T4 point

假设有一条直线在负无穷的位置,然后慢慢往后,直线会慢慢产生交点,从而转化为求逆序对

????????????

后面的题基本全没听懂

最短的一篇博客,因为啥也没听懂,心态炸裂

原文地址:https://www.cnblogs.com/57xmz/p/13779742.html