# Link
https://www.acmicpc.net/problem/1526
1526번: 가장 큰 금민수
첫째 줄에 N이 주어진다. N은 4보다 크거나 같고 1,000,000보다 작거나 같은 자연수이다.
www.acmicpc.net
# Code - C++
//
// BOJ
// ver.C++
//
// Created by GGlifer
//
// Open Source
#include <iostream>
#include <queue>
using namespace std;
#define endl '\n'
#define len(x) (int)(x).length()
#define size(x) (int)(x).size()
#define str(x) to_string(x)
#define error logic_error("line " + str(__LINE__))
// Set up : Definitions
/* None */
// Set up : Global Variables
/* None */
// Set up : Functions Declaration
/* None */
int main()
{
// Set up : I/O
ios::sync_with_stdio(false);
cin.tie(nullptr);
// Set up : Input
int N; cin >> N;
// Process
queue<int> Q;
Q.push(0);
int ans = -1;
while (not(Q.empty())) {
int c = Q.front(); Q.pop();
if (c > N) continue;
ans = c;
Q.push(10*c + 4);
Q.push(10*c + 7);
}
// Control : Output
cout << ans << endl;
}
// Helper Functions
/* None */
지적, 조언, 첨언 모두 환영합니다!!!
'Problem Solving > 백준' 카테고리의 다른 글
[ Problem Solving :: 백준 ] 2456 / 나는 학급회장이다 (0) | 2021.11.25 |
---|---|
[ Problem Solving :: 백준 ] 2473 / 세 용액 (0) | 2021.11.16 |
[ Problem Solving :: 백준 ] 11558 / The Game of Death (0) | 2021.11.16 |
[ Problem Solving :: 백준 ] 2698 / 인접한 비트의 개수 (0) | 2021.11.16 |
[ Problem Solving :: 백준 ] 14606 / 피자 (Small) (0) | 2021.11.16 |