51Nod 1087 1 10 100 1000

打表,把所有\(1\)出现的位置存起来。

unordered_set<int> S;

void init()
{
    for(int i=1,d=1;i<=1e9;)
    {
        S.insert(i);
        i+=d;
        d++;
    }
}

int main()
{
    init();

    int T;
    cin>>T;
    while(T--)
    {
        int x;
        cin>>x;
        if(S.count(x)) cout<<1<<endl;
        else cout<<0<<endl;
    }
    //system("pause");
    return 0;
}
posted @ 2021-04-05 15:54  Dazzling!  阅读(27)  评论(0编辑  收藏  举报