Skip to content

Instantly share code, notes, and snippets.

@NixImagery
Created June 23, 2017 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NixImagery/8dc1db4fbee2d33c9330b3ccf9aa6d52 to your computer and use it in GitHub Desktop.
Save NixImagery/8dc1db4fbee2d33c9330b3ccf9aa6d52 to your computer and use it in GitHub Desktop.
int main(){
int t;
cin >> t;
vector<long> p;
for (int a=100001; a < 900010; a+=100001)
for (int b = 0; b < 90091; b+=10010)
for (int c = 0; c < 9901; c+=1100)
p.push_back(a + b + c);
sort(p.begin(), p.end());
p.push_back (0);
vector<long> xx;
for(int x = 100; x < 1000; ++x){
for (int y = 100; y < x; ++y){
long xy = x * y;
if (binary_search(p.begin(),p.end(),xy))
xx.push_back(xy);
}
}
sort(xx.begin(),xx.end());
for(int a0 = 0; a0 < t; a0++){
long n;
cin >> n;
vector<long>::iterator ans = lower_bound(xx.begin(),xx.end(),n) - 1;
cout << *ans << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment