728x90
- 문제
https://www.acmicpc.net/problem/17863
17863번: FYI
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 informatio
www.acmicpc.net
- 풀이법
앞 3자리가 555이면 되기 때문에 for문을 통해 앞에서부터 3번째까지 모두 5인지 확인해주었다.
- 풀이 - C++
#include <iostream>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string input;
cin >> input;
bool flag = true;
for(int i = 0; i < 3; i++) if(input[i] != '5') flag = false;
if(flag) cout << "YES";
else cout << "NO";
return 0;
}
728x90
'PS > 백준' 카테고리의 다른 글
[ 백준 ] 3036번 : 링 - (CPP/C/C++) (0) | 2022.06.08 |
---|---|
[ 백준 ] 17298번 : 오큰수 - (CPP/C/C++) (0) | 2022.06.08 |
[ 백준 ] 14489번 : 치킨 두 마리 (...) - (CPP/C/C++) (0) | 2022.06.08 |
[ 백준 ] 14581번 : 팬들에게 둘러싸인 홍준 - (CPP/C/C++) (0) | 2022.06.07 |
[ 백준 ] 11945번 : 뜨거운 붕어빵 - (CPP/C/C++) (0) | 2022.06.07 |