求助大佬,后三个测试点TLE,请问如何优化?
万分感谢
#include<iostream>
using namespace std;
int pasnum(int n)
{
int temp = n;
for (int i = 7; i <= temp; i++)
{
bool flag = 0;
int s = i;
while (s)
{
if (s % 10 == 7)
{
flag = 1;
s = 0;
}
s /= 10;
}
if (flag)n--;
}
return n;
}
int main()
{
int n, num[100001];
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> num[i];
num[i] = pasnum(num[i]);
}
for (int i = 1; i <= n; i++)
cout << num[i] << endl;
return 0;
}