分讨60,后两点不是wa是TLE...
查看原帖
分讨60,后两点不是wa是TLE...
128388
星之哀伤楼主2023/7/15 16:34
#include<bits/stdc++.h> 
using namespace std;
int count1(int a) {
int count = 0;
while(a!=1) {
a=a/2;
count++;
}
return count;
}
long long wei(long long n){
	int ui=n;
	int i8u=count1(n);
	int H[37];
	int c[3],te=1;
	memset(c,0,sizeof(c));
	for(int i=0;i<36;i++) H[(1ll<<i)%37]=i;
	while(n>0){
		c[te]=H[(n&-n)%37];
		n-=n&-n;
		te++;
	}
	if(c[2]==0) return ui+1;
	if(c[2]==i8u&&c[1]==i8u-1) return pow(2,(i8u+1));
	else return (ui+pow(2,c[1]));
}
bool ed(long long n){
	int H[37];
	for(int i=0;i<36;i++) H[(1ll<<i)%37]=i;
		int sum=0;
		while(n>0){
			sum++;
			n-=n&-n;
		}
		if(sum>=3) return 0;
		else return 1;
}
int main(){
  int T;
  long long op;
  cin>>T;
  while(T--){
  	cin>>op;
  	if(ed(op)==0) cout<<"No,Commander"<<endl;
	  else cout<<wei(op)<<endl;
	  } 
  }

//1100000000000 10000000000000
//1001000000000000 10000000000000000000000000000
2023/7/15 16:34
加载中...