백준 15439 자바
Vera and Outfits
문제
Vera owns N tops and N pants. The i-th top and i-th pants have colour i, for 1 ≤ i ≤ N, where all N colours are different from each other.
An outfit consists of one top and one pants. Vera likes outfits where the top and pants are not the same colour.
How many different outfits does she like?
입력
The input will be in the format:
N
Constraints:
- 1 ≤ N ≤ 2017
- N is integer
출력
Output one line with the number of different outfits Vera likes.
예제 입력 1
1
예제 출력 1
0
예제 입력 2
2
예제 출력 2
2
예제 입력 3
5
예제 출력 3
20
코드
import java.util.Scanner;
public class B15439 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
sc.close();
System.out.println(N * (N - 1));
}
}
'알고리즘 공부 > 백준 문제풀이' 카테고리의 다른 글
[백준] 10718 : We love kriii(JAVA) (0) | 2022.10.05 |
---|---|
[백준] 17362 : 수학은 체육과목 입니다 2(JAVA) (0) | 2022.10.05 |
[백준] 19963 : CASIO (JAVA) (0) | 2022.10.05 |
[백준] 10768 : 특별한 날(JAVA) (0) | 2022.10.05 |
[백준] 11948 : 과목선택(JAVA) (0) | 2022.10.05 |