fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner sc = new Scanner(System.in);
  13. int tc = sc.nextInt();
  14. int n;
  15. for(int z = 1; z <= tc; z++){
  16. n = sc.nextInt();
  17. System.out.printf("%d %d %d\n", z,n,ans(n));
  18. }
  19. }
  20. public static long ans(int x){
  21. long ans = 0;
  22. for(int i = 1; i <= x; i++){
  23. ans+=(i*(((i+1)*(i+2))/2));
  24. }
  25. return ans;
  26. }
  27. }
Success #stdin #stdout 0.09s 380672KB
stdin
4
3
4
5
10
stdout
1 3 45
2 4 105
3 5 210
4 10 2145