- Are green plastic bottles suitable for making a cold frame/greenhouse?
- Does 2 weeks before the last frost mean when the ground is still frozen?
- What did the Greeks call the “trial and error” reasoning process?
- Differentiating いなくなる as “not being around” versus “not being around (because of being dead)”?
- Zu sehen vs sehen
- How to logout user if idle
- SharePoint 2016 Managed Navigation Import CSV Parameter Mapping
- Sharepoint 365 Folder Permissions
- Fuel Pressure Relief Procedures - Evaluating Different Approaches
- how to know when to replace the starter
- 2007 Dodge Charger 2.7L CPS - What Company(s) Does Dodge Use for OEM?
- Display Suite Extra Fields not showing in content page
- Can't get url from internal uri in twig template file
- So, running Drush update messed up your SVN repo
- Concatenating translatable strings is not allowed, use placeholders instead and only one string literal
- views export in jsonapi format
- What are good aqua exercises for a person who has had a total knee replacement with subsequent manipulation?
- Why does iterative formula for finite differences (explicit or other) hold with equality when BS PDE is an inequality (pricing american opti
- Local Volatility implementation
- For pricing, what types of Exotic Options are suitable using Local Volatility Model / Stochastic Volatility Model?

# Recursively calculate the product of the non-zero digits of a range of numbers

CodeForces "Recursive Queries"

Each query consists of three integers \$l\$, \$r\$, and \$k\$. Print the number of integers \$x\$ that satisfy \$l \le x \le r\$ and \$g(x)=k\$, where

$$\begin{align}

f(n) =&\ \textrm{product of non-zero digits of }n \\

g(n) =&\ \cases{n &if $n<10$ \\ g(f(n)) &otherwise}

\end{align}$$

\$1 \le l \le r \le 10^6\$, and \$1 \le k \le 9\$.

I tried to solve this problem but am getting time limit exceeded on test 8.

#include

#include

#include

#include

long int ara[10][1000010];

long int fnc(long int n){

long int p=1,r;

if(n<10){

return n;

}

else{

while(n!=0){

r=n%10;

if(r!=0){

p=p*r;

}

n=n/10;

}

}

fnc(p);

}

int main()

{

long int q,j;

for(j=1;j<1000009;j++){

ara[fnc(j)][j]=1;

}

scanf("%ld",&q);

while(q--)

{

long int l,r,k,i,count=0;

scan