Loading...
Submission
Id When Author Problem Language CPU Memory Verdict
17889 2024-04-24 03:52:41 dnt Sum Game II Java 1102 ms 42232 kb Time Limit Exceeded - 4
Test Cases
CPU Memory Verdict
1 103 ms 38648 kb Accepted
2 108 ms 42148 kb Accepted
3 107 ms 42232 kb Accepted
4 1102 ms 652 kb Time Limit Exceeded
5 - - Skipped
6 - - Skipped
7 - - Skipped
Source Code
program.java
Download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6.  
  7. // Read the number of test cases
  8. int t = sc.nextInt();
  9.  
  10. for (int i = 0; i < t; i++) {
  11. // Read the number of friends
  12. long n = sc.nextLong();
  13.  
  14. // Calculate the sum of numbers from 0 to n-1
  15. long sum = 0;
  16. for (long j = 0; j < n; j++) {
  17. sum += j;
  18. }
  19.  
  20. // Output the sum
  21. System.out.println(sum);
  22. }
  23. }
  24. }
  25.