51Nod - 1596

题目链接:51Nod - 1596


水题,肯定是能组合就组合。


AC代码:

#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=1e6+50;
int cnt[N],n,x,res;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);	cnt[x]++;
		while(cnt[x]>=2)	cnt[x]-=2,cnt[++x]++;
	}
	for(int i=0;i<N;i++)	if(cnt[i])	res++;
	cout<<res;
	return 0;
}
发布了579 篇原创文章 · 获赞 242 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/weixin_43826249/article/details/104325150