fork(1) download
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4. using namespace std;
  5.  
  6. long long p, maxn, maxid, res = 1;
  7. vector<int>vec;
  8. int primes[16] = { 1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 };.
  9. void dfs(long long q, long long r) {
  10. long long sum = q;
  11. for (int i = 1; i <= 1000; i++) {
  12. if (sum > p) { break; }
  13. if (i >= 2) {
  14. vec.push_back(i); res *= i;
  15. if (res > maxn) { maxn = res; maxid = sum; }
  16. else if (res == maxn && maxid > sum) { maxid = sum; }
  17. dfs(sum, i);
  18. }
  19. sum *= primes[vec.size()];
  20. }
  21. res /= vec[vec.size() - 1];
  22. vec.pop_back();
  23. return;
  24. }
  25.  
  26. int Q;
  27.  
  28. int main() {
  29. cin >> Q;
  30. for (int i = 0; i < Q; i++) {
  31. vec.clear(); maxn = 1; res = 1; maxid = 1;
  32. vec.push_back(1);
  33. cin >> p;
  34. dfs(1, 20);
  35. cout << maxn << ' ' << maxid << endl;
  36. }
  37. return 0;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
2016
423
compilation info
prog.cpp:8:65: error: expected unqualified-id before '.' token
 int primes[16] = { 1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 };. 
                                                                 ^
stdout

Standard output is empty