반응형
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 |
Tags
- dfs
- compose
- 이분탐색
- 경력
- incr
- Kafka
- boj #19237 #어른 상어
- Docker
- 백준
- 퇴사통보
- 성적평가
- BFS
- OFFSET
- 처우산정
- 소프티어
- 6987
- 기술면접
- msSQL
- 매개변수탐색
- 물채우기
- 처우협의
- 연결요소
- BOJ
- 백트래킹
- 오퍼레터
- softeer
- 13908
- @P0
- upper_bound
- 파라메트릭
Archives
- Today
- Total
기술 블로그
2231번 분해합 본문
728x90
반응형
https://www.acmicpc.net/problem/2231
시간초과 뜰 줄 알았는데 안 떴다.
1이상 100만이하 모든 수를 탐색할 수 밖에 없는 문제인 것 같다.
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 32 33 34 35 36 37 38 39 40 41 42 43 | #include <iostream> #include <queue> #include <stack> #include <cstdio> #include <vector> #include <cstring> #include <string> #include <math.h> #include <algorithm> #include <map> using namespace std; int MIN = INT32_MAX; void DivideSum(int N) { for (int i = 1; i <= 1000000; i++) { string str = to_string(i); int sum = i; for (int j = 0; j < str.length(); j++) sum += str[j] - '0'; if (sum == N) MIN = min(MIN, i); } } int main(void) { int N = 0; scanf("%d", &N); DivideSum(N); if(MIN != INT32_MAX) printf("%d\n", MIN); else printf("0\n"); return 0; } | cs |
728x90
반응형
'알고리즘 문제 > BOJ' 카테고리의 다른 글
5567번 결혼식 (0) | 2018.12.24 |
---|---|
9372번 상근이의 여행 (0) | 2018.12.19 |
1065번 한수 (0) | 2018.12.18 |
2161번 카드1 (0) | 2018.12.15 |
1018번 체스판 다시 칠하기 (0) | 2018.12.14 |