Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 17863번 FYI 본문

YJ/C++

[백준/BOJ/C++] 17863번 FYI

Team DAON 2021. 10. 22. 14:37

[문제]

In the United States of America, telephone numbers within an area code consist of 7 digits: the prefix number is the first 3 digits and the line number is the last 4 digits. Traditionally, the 555 prefix number has been used to provide directory information and assistance as in the following examples:

  • 555-1212
  • 555-9876
  • 555-5000
  • 555-7777

Telephone company switching hardware would detect the 555 prefix and route the call to a directory information operator. Now-a-days, telephone switching is done digitally and somewhere along the line a computer decides where to route calls.

For this problem, write a program that determines if a supplied 7-digit telephone number should be routed to the directory information operator, that is, the prefix number is 555.

 

[입력]

The input consists of a single line containing a 7-digit positive integer N, (1000000 <= N <= 9999999).

 

[출력]

The single output line consists of the word YES if the number should be routed to the directory information operator or NO if the number should not be routed to the directory information operator.

 

[Source Code]

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int test = 0;
	string number;
	cin >> number;
	
	for(int i = 0; i < 3; i++){
		if(number[i] != '5')
			test = 1;
	}

	if(test == 1)
		cout << "NO";
	else
		cout << "YES";
}

[결과 화면]