※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※

 

이번에 볼 문제는 백준 10693번 문제인 Abdelrahman이다.
문제는 아래 링크를 확인하자.

https://www.acmicpc.net/problem/10693 

 

10693번: Abdelrahman

In an ICPC national contest after the operations team had arrived to the site, they discovered that a mistake had been made in connecting the network of computers that the contestants will use, and many unneeded cables has been installed between the comput

www.acmicpc.net

N개의 컴퓨터가 서로 연결되어있게 하기 위해 필요한 최소 케이블 수는 N-1개이다. N개의 컴퓨터가 이미 모두 연결되어있다면 N-1개의 케이블만을 남겨 모든 컴퓨터가 연결되어있게 하는 것 또한 가능하다. (spanning tree 참고)

 

답을 출력할 때 많은 다른 문제외 달리 각 케이스의 번호 앞에 '#'을 출력하면 안됨에 유의하자.

 

아래는 제출한 소스코드이다.

#include <iostream>
using namespace std;

int T;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> T;
	for (int t = 1; t <= T; t++) {
		int x, y; cin >> x >> y;
		cout << "Case " << t << ": " << y - x + 1 << '\n';
	}
}
728x90

+ Recent posts