社区讨论

70 pts 求 hack

P15458【MX-X25-T2】『FeOI-5』2 的次幂参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@mm4mbv35
此快照首次捕获于
2026/02/27 16:16
上周
此快照最后确认于
2026/03/01 11:25
上周
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 1e6 + 5;
int n;

bool check(int x){
	return ((x & (x + 1)) == 0);
}

void solve(){
	cin >> n;
	int c1 = 0, c2 = 0, ans = 0;
	for(int i = 1, x; i <= n; ++ i){
		cin >> x;
		if(x == 1) ++ c1;
		else if(x == 0) continue;
		else if(check(x)) ++ c2, ans += __lg(x);
		else ans += __lg(x);
//		cout << "?" << ans << "\n";
	}
//	cout << "!" << c1 << " " << c2 << "\n";
	ans += min(c1, c2);
	cout << ans << "\n";
}

signed main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	int c, T;
	cin >> c >> T;
	while(T --)
		solve();
	
	return 0;
}

回复

2 条回复,欢迎继续交流。

正在加载回复...