跳到正文

题解

CF1570D

Vitamin_B约 1 分钟
原文
文章信息与版本

文章信息

发布
2023年9月21日
收录
2025年12月12日
更新
2026年11月8日
篇幅
约 1 分钟
题目
CF1570D

版本

  1. v1当前

题目传送门 & CF 传送门

思路

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

这题只要纯模拟就行了。不难发现,这题中的 nn 最终一定会变成一位数。到了一位数之后,nn 就会在 1∼91\sim 9 之间循环,不会出现别的数字了。所以,我们的标记数组只要定义 1∼91\sim9 就够了,不需要别的题解那样用 map 标记。

代码

C++
# 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;
		}
	}
}
原文