我的代码能对是能对,就是超时了,求各位帮忙优化一下,感谢。(11,12,13号点超时)
#include <bits/stdc++.h>
using namespace std;
long long t,a,ans;
inline bool check_7(long long num){
	long long ts = num;
	bool not_have_7 = true;
	while(ts){
		if(ts%10 == 7){
			not_have_7 = false;
			break;
		}
		ts/=10;
	}
	return not_have_7;
}
int main(){
	scanf("%lld",&t);
	while(t--){
		ans = 0;
		scanf("%lld",&a);
		for(long long i=1;i<=a;++i){
			if(check_7(i)){
				++ans;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}