简答题
偏难
#20132
优美的数字
优美的数字

答案与解析
正确答案:<pre><code>#include <algorithm>
#include <cstdio>
using namespace std;
int n, ans = 0;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int v = i % 10;
int t = i / 10;
int chk = 1;
while (t) {
if (t % 10 != v) {
chk = 0;
// 找到不同数字可以直接跳出循环,优化
break;
}
t /= 10;
}
ans += chk;
}
printf("%d\n", ans);
return 0;
}</code></pre>
这道题暂未补解析。