Advertisement
bkit4s0

[anuwta]

Jul 7th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. class anuwta {
  6.     public static void main(String[] args) throws IOException {
  7.         BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
  8.         int t = Integer.parseInt(b.readLine());
  9.         while (t-- > 0) {
  10.             int n = Integer.parseInt(b.readLine());
  11.             long result = calcDistanceYouWalked(n);
  12.             System.out.println(result);
  13.         }
  14.     }
  15.  
  16.     private static long calcDistanceYouWalked(int n) {
  17.         // TODO Auto-generated method stub
  18.         return (n + 1) * (n + 2) / 2 - 1;
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement