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 | #include <iostream> #include <stdio.h> using namespace std; int main(void) { int ref, num, cycle=0; cin >> num; ref = num; while(true) { if(num < 10) { num = num*10 + num; } else { num = (num%10)*10 + (num%10 + num/10)%10; } cycle++; if(num == ref) break; } cout << cycle << endl; return 0; } | cs |
'C & C++ > Baekjoon' 카테고리의 다른 글
백준 1157 - 단어 공부 (0) | 2017.12.27 |
---|---|
백준 1152 - 단어의 개수 (0) | 2017.12.27 |
백준 1065 - 한수 (0) | 2017.12.27 |
백준 1008 - A/B (0) | 2017.12.27 |
백준 1003 - 피보나치 함수 (0) | 2017.12.27 |