Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- int val = Convert.ToInt32(Console.ReadLine());
- for (int i = 0; i < val; i++)
- {
- int[] num = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToArray();
- int X = 0;
- for (int j = num[0] ; j < num[1]+1 ; j++)
- {
- if (g(j) == num[2])
- {
- X++;
- }
- }
- Console.WriteLine(X);
- }
- }
- static int f(int ch)
- {
- int result = 1;
- while (ch != 0)
- {
- int cif = (ch % 10);
- if (cif > 1)
- {
- result *= cif;
- }
- ch /= 10;
- }
- return result;
- }
- static int g(int ch)
- {
- return ch < 10 ? ch : g(f(ch));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement