首页 > 其他 > 详细

51Nod 1087 1 10 100 1000

时间:2021-04-05 17:18:58      阅读:21      评论:0      收藏:0      [点我收藏+]

打表,把所有\(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;
}

51Nod 1087 1 10 100 1000

原文:https://www.cnblogs.com/fxh0707/p/14618593.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!