题目链接:https://vjudge.net/problem/51Nod-1087
思路:

#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
const int maxn = 1000000005;
int main()
{
    set<int> s;
    set<int> :: iterator it;
    int num=1,a=1;
    while(num<maxn)
    {
        s.insert(num);
        num+=a;
        a++;
    }
    int T,b;
    cin>>T;
    while(T--)
    {    
        cin>>b;
        it=s.find(b);
        if(it!=s.end())
        {
            cout<<"1"<<endl;
        }    
        else cout<<"0"<<endl;
        
    }
    return 0;        
}
Last modification:September 19th, 2019 at 12:20 am
如果觉得我的文章对你有用,请随意赞赏