为了AC,也是拼了!60分TLE求助!
查看原帖
为了AC,也是拼了!60分TLE求助!
922691
Hisy楼主2023/8/18 17:35
#include<cstdio>
inline void read(int &in){
    in=0;
    int minus=1;
    char got=getchar();
    while('9'<got||got<'0'){
        if(got=='-'){
            minus=-1;
        };
        got=getchar();
    };
    while('0'<=got&&got<='9'){
        in=in*10+got-'0';
        got=getchar();
    };
    in*=minus;
};
inline void write(const int &out){
    if(out<0){
        putchar('-');
    };
    if(out/10){
        write(out/10);
    };
    putchar(out%10+'0');
};
inline bool popcount(int judge){
	int sum=0;
	while(judge){
		if(judge%2){
			sum++;
		};
		judge/=2;
	};
	return sum>=3;
};
inline int nextcount(int judge){
	int ans=judge+1;
	while(popcount(ans)){
		ans++;
	};
	return ans;
};
int main(int argc,char **argv){
	int maxn;
	int temp;
	read(maxn);
	while(maxn--){
		read(temp);
		if(popcount(temp)){
			putchar('N');
			putchar('o');
			putchar(',');
			putchar('C');
			putchar('o');
			putchar('m');
			putchar('m');
			putchar('a');
			putchar('n');
			putchar('d');
			putchar('e');
			putchar('r');
			putchar('\n');
		}else{
			write(nextcount(temp));
			putchar('\n');
		};
	};
	return 0;
};
2023/8/18 17:35
加载中...