CF1570D

题目传送门 & CF 传送门

思路

这题做不了,所以只有一个人通过了。

这题只要纯模拟就行了。不难发现,这题中的 nn 最终一定会变成一位数。到了一位数之后,nn 就会在 191\sim 9 之间循环,不会出现别的数字了。所以,我们的标记数组只要定义 191\sim9 就够了,不需要别的题解那样用 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;
		}
	}
}
posted @ 2023-09-21 09:58  Vitamin_B  阅读(7)  评论(0)    收藏  举报  来源