In the program I have taken T as the number of test cases.
I am learning precomputation in which I have precomputed all the product of the digits of the numbers and their sizes from 0–>n in two different vectors.
The first line of input is n.
The code is not giving any output sadly, please help me out!
Also it would be great if you could suggest me a better alternative which would have a faster Time Complexity (Want to make it lesser than 1 second)
using namespace std;
const int N=10;
const long long M=1e7;
int main()
{
vector<long long> product;
vector<long long> size;
for(int i=0;i<M;i++)
{
int pl=1,count=0;
int num=i;
if(num==0)
pl=0;
else
{
while(num != 0)
{
pl = pl * (num % 10);
num = num / 10;
count++;
}
}
product[i]=pl;
size[i]=count;
}
int t;
cin>>t;
while(t--)
{
long long n;
cin>>n;
for(int i=0;i<=n;i++)
{
cout<<size[i]<<" "<<product[i]<<endl;
}
}
return 0;
} ```