#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int t; cin>>t; while(t--) { vector<long long> a; long long l,p,q; cin>>l; p=l;q=-1; while(1) { q++; long long m=l*(l+1); std::vector<long long>::iterator it; it = find(a.begin(), a.end(), m/2); if(it!=a.end()){ break; } a.push_back(m); l++; } cout<<p+q<<endl; } } |
Double click to view unformatted code.