CF1570D
思路
这题做不了,所以只有一个人通过了。
这题只要纯模拟就行了。不难发现,这题中的 最终一定会变成一位数。到了一位数之后, 就会在 之间循环,不会出现别的数字了。所以,我们的标记数组只要定义 就够了,不需要别的题解那样用 map 标记。
代码
# include <bits/stdc++.h>
using namespace std;
int n, tot;
bool vis[15];
int main () {
cin >> n;
while (1) {
++ n, ++ tot;
while (! (n % 10))
n /= 10;
if (n < 10) {
if (vis[n]) {
cout << tot;
return 0;
}
vis[n] = 1;
}
}
}

浙公网安备 33010602011771号