๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm ๐Ÿง‘๐Ÿป‍๐Ÿ’ป/๋ฐฑ์ค€(BOJ)

[๋ฐฑ์ค€,c++] 1110๋ฒˆ - ๋”ํ•˜๊ธฐ ์‚ฌ์ดํด

by dkswnkk 2021. 10. 27.
#include <iostream>
#include <string>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string check; cin >> check;
    string cycle;
    int cnt = 0;

    if (check.length() == 1) {
        check = "0" + check;
    }
    cycle = check;
    while (true) {
        int temp = stoi(cycle) / 10 + stoi(cycle) % 10;
        int temp3 = stoi(cycle) % 10;
        cycle = to_string(temp3) + to_string(temp % 10);
        if (check == cycle) break;
        else cnt++;
    }
    cout << cnt + 1;
}

๋Œ“๊ธ€