超时了 是while不对嘛
查看原帖
超时了 是while不对嘛
427617
蒟蒻珂学家楼主2021/1/13 13:35
#include <iostream>
using namespace std;
int main(){
    int n, x, cnt = 0;
    cin >> n >> x;
    for(int i = 1; i <= n; i++){
        while(i >= 0){
            if(i % 10 == x){
                cnt++;
            }i /= 10;
        }
    }cout << cnt;
    return 0;
}
2021/1/13 13:35
加载中...