暴力 60分WA 求调
查看原帖
暴力 60分WA 求调
678217
kingradshj楼主2022/8/27 16:18

以下时代码求大佬调试

#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL l,r,ans,tong[10];
bool f(LL x){
	tong[1]=0,tong[0]=0;
	while(x!=0){
		tong[x%2]++;
		x/=2;
	}
	if(tong[1]<=tong[0]) return true;
	else return false;
}
int main(){
	cin>>l>>r;
	for(LL i=l;i<=r;++i){
		if(f(i)==true){
			ans++;
		} 
	}
	cout<<ans;
	return 0;
}
2022/8/27 16:18
加载中...