Skip to content

Instantly share code, notes, and snippets.

@johirbuet
Created February 27, 2018 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johirbuet/e54e875caaa4f73c3155a4c898c9bc04 to your computer and use it in GitHub Desktop.
Save johirbuet/e54e875caaa4f73c3155a4c898c9bc04 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class UVA12918 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
while(T-->0) {
int n = sc.nextInt();
int m = sc.nextInt();
int extra = m - n;
int sum = n * extra;
sum = sum + (n-1)*n/2;
System.out.println(sum);
}
sc.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment