某蒟蒻C++报超时求助dalao
查看原帖
某蒟蒻C++报超时求助dalao
1297689
xzx2013楼主2024/5/26 17:33
#include <cstdio>
using namespace std;
int main()
{
    int n,x,num;
    scanf("%d %d",&n,&x);
    for (int i = 1;i <= n;i++)
    {
        while (i > 0)
        {
            if (i % 10 == x)
            {
                num += 1;
            }
            i /= 10;
        }
        
    }
    printf("%d",num);
    return 0;
}

本蒟蒻敢问各位dalao能不能看一下这为啥会超时?

2024/5/26 17:33
加载中...