比赛 |
2016-10-11 4 syz |
评测结果 |
AAAAAAAAAA |
题目名称 |
无穷的序列 |
最终得分 |
100 |
用户昵称 |
Tabing010102 |
运行时间 |
0.708 s |
代码语言 |
C++ |
内存使用 |
0.48 MiB |
提交时间 |
2016-10-11 19:43:40 |
显示代码纯文本
#include <cstdio>
#include <algorithm>
using namespace std;
FILE *fin, *fout;
int A[50001], n;
int main() {
fin = fopen("unlessseq.in", "r");
fout = fopen("unlessseq.out", "w");
// fout = stdout;
for(int i = 1; i <= 50000; i++) A[i] = A[i-1]+i;
// for(int i = 0; i <= 50000; i++) fprintf(fout, "%d\n", A[i]);
fscanf(fin, "%d", &n);
for(int i = 1; i <= n; i++) {
int p;
fscanf(fin, "%d", &p);
int tmp = lower_bound(A, A+50000, p-1) - A;
// fprintf(fout, "%d\n", A[tmp]);
if(A[tmp] == p-1) fprintf(fout, "1\n");
else fprintf(fout, "0\n");
}
return 0;
}