fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7. PrintWriter out = new PrintWriter(System.out);
  8.  
  9. long a = in.nextLong();
  10. long b = in.nextLong();
  11. long n, S;
  12. n = b - a + 1;
  13. S = (a + b) * n / 2;
  14. out.print(S);
  15.  
  16. out.flush();
  17. }
  18. }
Success #stdin #stdout 0.07s 2184192KB
stdin
249 318
stdout
19845