您的位置:首页 > 其它

51nod 1087 1 10 100 1000

2016-09-19 21:58 337 查看
51nod 1087 1 10 100 1000

简单思维题,容易发现是1的下标为:1 2 4 7 11,它们的相邻差不断++,推出下标x符合:x = (n-1)*n/2+1;

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define PI acos(-1.0)
#define E 2.71828
#define MOD 1000000007
#define N 1010

int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
n = (n-1)*2;
int x = (int)sqrt(n);
if( x*(x+1)== n)
printf("1\n");
else
printf("0\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: