最后三个超时了,求助
  • 板块P1590 失踪的7
  • 楼主CKAO
  • 当前回复0
  • 已保存回复0
  • 发布时间2021/12/19 22:07
  • 上次更新2023/10/28 14:02:11
查看原帖
最后三个超时了,求助
583126
CKAO楼主2021/12/19 22:07
#include<iostream>
using namespace std;
int add(int n)
{
    while (n!=0)
    {
        if (n%10==7)
            return 0;
        n/=10;
    }
    return 1;
}
int main()
{
    int t;
    cin>>t;
    while (t--)
    {
        int n,res=0;
        cin>>n;
        for (int i=1;i<=n;i++)
            if (add(i)==1)
                res++;
        cout<<res<<endl;
    }   
    return 0;
}
2021/12/19 22:07
加载中...