求 hack
查看原帖
求 hack
179187
SuperAlex4楼主2024/9/2 13:07

起因:被坏心眼子学弟推题然后真的写了

#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0; bool f=1; char c=getchar();
	while(c<48||c>57) f^=(c==45), c=getchar();
	while(c>=48&&c<=57) x=x*10+(c&15), c=getchar();
	return f?x:-x;
}
priority_queue<int> q;
int n, a, b; long long ans=0;
int main(){
	n=read(), a=read(), b=read();
	for(int i=1; i<=n; i++) q.push(read());
	while(a>1) q.push(sqrt(q.top())), q.pop(), a--;
	if(a){
		int x=q.top(), y=sqrt(x); q.pop();
		if(n>1&&b&&(y&1)&&x==y*y&&q.top()==y*y-1)
			q.pop(), q.push(x>>1), q.push(y-1), b--;
		else q.push(y);
	}
	while(b) q.push(q.top()>>1), q.pop(), b--;
	while(!q.empty()) ans+=q.top(), q.pop();
	cout<<ans<<endl;
	return 0;
}
2024/9/2 13:07
加载中...