Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 코테
- 컴공
- 구현
- 북리뷰
- 브루트포스
- Operating System
- c++
- 알고리즘
- cs
- 자료구조
- 오에스
- Computer science
- Stack
- 정석학술정보관
- coding
- 정석
- 너비우선탐색
- 백준
- 코딩
- OS
- vector
- 오퍼레이팅시스템
- 문제풀이
- 컴퓨터공학과
- 그래프
- bfs
- 스택
- 개발
- 컴공과
- DP
Archives
- Today
- Total
Little Jay
[C++] 백준 6679번 - 싱기한 네자리 숫자 본문
진법 계산을 요구하는 Brute Force 문제
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
const int numbers[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
bool check(int dec, int hex, int doz) {
return (dec == hex && hex == doz);
}
int dozen_calc(int n) {
int doz_num = 0;
int temp = n;
while (temp) {
doz_num += numbers[temp % 12];
temp /= 12;
}
return doz_num;
}
int hex_calc(int n) {
int hex_num = 0;
int temp = n;
while (temp) {
hex_num += numbers[temp % 16];
temp /= 16;
}
return hex_num;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
for (int i = 2992; i < 10000; i++) {
int temp = i;
int dec_num = 0;
dec_num += temp / 1000;
temp %= 1000;
dec_num += temp / 100;
temp %= 100;
dec_num += temp / 10;
temp %= 10;
dec_num += temp;
if (check(dec_num, hex_calc(i), dozen_calc(i))) cout << i << endl;
}
return 0;
}
'알고리즘 > BOJ' 카테고리의 다른 글
[C++] 백준 13565번 - 침투 (0) | 2022.05.03 |
---|---|
[C++] 백준 14464번 - 소가 길을 건너간 이유 4 (0) | 2022.04.27 |
[C++] 백준 1655번 - 가운데를 말해요 (0) | 2022.03.14 |
[C++]백준 5014번 - 면접에 늦었다 (0) | 2022.03.14 |
[C++] 백준 11055번 - 가장 큰 증가 부분 수열 (0) | 2022.02.21 |
Comments