求助subtask #1 WA了
查看原帖
求助subtask #1 WA了
807266
houwz351楼主2023/7/3 20:42

RT
代码:

#include <bits/stdc++.h>
using namespace std;
int n,a;
template < typename T > void read(T & ff) {
    T rr = 1;
    ff = 0;
    char ch = getchar();
    while (!isdigit(ch)) { if (ch == '-') rr = -1; ch = getchar(); }
    while (isdigit(ch)) { ff = (ff << 1) + (ff << 3) + (ch ^ 48); ch = getchar(); }
    ff *= rr;
}
inline void write(int x) {
    if (x < 0) putchar('-'),x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
bool pd(int x){
	int delta=8*x-7;
	if(delta<=0){
		return 0;
	}
	int t=sqrt(delta);
	if((t*t)^delta){
		return 0;	
	}
	if(!(t&1)){
		return 0;
	}
	return 1;
}
int main(){
	read(n);
	while(n--){
		read(a);
		if(pd(a)){
			write(1);
			putchar('\n');
		}
		else{
			write(0);
			putchar('\n');
		}
	}
	return 0;
}

结论自己推的可能有误求指出

2023/7/3 20:42
加载中...