 # Why am I not getting any output?

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.
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;
} `````````

bro u are doing a huge mistake in your Code.initially the size of vector is empty and you are changing their values.it will give Run Time Erro.Give Your vectors some size initially.

``````vector<long long> product(M);
vector<long long> size(M);
``````

i have idea for better solution.if u are finding the product of digits of a number like 123456.
you are doing logn operations,you can do that in O(1) time.like-
find the product of 12345 in product array and multiply with 6 after that,and same will work for size as well.

Can you please show me the code? I could’nt get you