fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int t, n, i, ans, a[10];
  7.  
  8. int main() {
  9. int t;
  10. scanf("%d", &t);
  11. while (t--) {
  12. scanf("%d", &n);
  13. for (i = 0 ; i < n; ++i) scanf("%d", a + i);
  14. sort(a, a + n);
  15. ++a[0]; // https://a...content-available-to-author-only...g.com/wiki/index.php/AM-GM_Inequality
  16. for (i = 0, ans = 1 ; i < n ; ++i) ans *= a[i];
  17. printf("%d\n", ans);
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5284KB
stdin
4
4
2 2 1 2
3
0 1 2
5
4 3 2 3 4
9
9 9 9 9 9 9 9 9 9
stdout
16
2
432
430467210