Created
February 27, 2018 18:58
-
-
Save johirbuet/e54e875caaa4f73c3155a4c898c9bc04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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