https://www.acmicpc.net/problem/16676
처음 제출 했을 때, 0인 경우를 생각 못해서 틀렸습니다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <iostream> #include <cstdlib> using namespace std; int main(){ int n,chk_n; string s_chk_n; cin >> n; string s = to_string(n); int size = s.size(); for(int i = 0; i < size; i++) s_chk_n+='1'; chk_n = atoi(s_chk_n.c_str()); if(n>=chk_n) cout << size; else if(n == 0) cout << 1; else cout << size-1; } | cs |
반응형
'프로그래밍 > 문제풀이' 카테고리의 다른 글
[etc] 백준 10757 큰 수 A+B (0) | 2019.01.29 |
---|---|
[etc] 백준 16678 모독 (0) | 2019.01.27 |
[etc] 백준 16674 2018년을 되돌아보며 (0) | 2019.01.22 |
[bfs] 백준 16569 화산쇄설류 (0) | 2019.01.17 |
[etc] 백준 13118 뉴턴과 사과 (0) | 2019.01.15 |