简答题 偏难
#20132

优美的数字

优美的数字

未登录也能判分,登录后才会记录
答案与解析
正确答案:<pre><code>#include &lt;algorithm&gt; #include &lt;cstdio&gt; using namespace std; int n, ans = 0; int main() {   scanf("%d", &amp;n);   for (int i = 1; i &lt;= 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>
这道题暂未补解析。