您的位置:首页 > 其它

URAL 1209 110100100010000……

2011-08-04 08:34 309 查看
/*
此题纠结了n久
感觉自己的方法应该是最高效的解法了
但每次提交都超时
后来发现原来是上界弄错了
无语。。。
*/
#define LOCAL
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int n,first=1;double k;unsigned long t;
cin>>n;
while(n--){
cin>>k;
t=(long)sqrt(2*k);//就是这得上界弄错了
while((t*(t+1))>(2*(k-1))) t-=1;
if((t*(t+1))==(2*(k-1)))
{if(first){cout<<1;first=0;}
else{cout<<" 1";}}
else{if(first){cout<<0;first=0;}
else{cout<<" 0";}}}
cout<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: