본문 바로가기
Study (etc)/Problem Solving

[BOJ / C++] 15439번 : Vera and Outfits

by Haren 2023. 3. 30.

문제

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.

Solved.ac 레벨

브론즈 IV

풀이

#include <bits/stdc++.h>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;

    cin >> n;

    cout << n * (n - 1) << "\n";

    return 0;
}

 

 

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.

www.acmicpc.net