Advertisement
MyOnAsSalat

Untitled

Feb 15th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         int val = Convert.ToInt32(Console.ReadLine());
  9.         for (int i = 0; i < val; i++)
  10.         {
  11.             int[] num = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToArray();
  12.             int X = 0;
  13.             for (int j = num[0] ; j < num[1]+1 ; j++)
  14.             {            
  15.                 if (g(j) == num[2])
  16.                 {
  17.                     X++;
  18.                 }
  19.             }
  20.             Console.WriteLine(X);
  21.         }
  22.     }
  23.      static int f(int ch)
  24.     {
  25.         int result = 1;
  26.         while (ch != 0)
  27.         {
  28.             int cif = (ch % 10);
  29.             if (cif > 1)
  30.             {
  31.                 result *= cif;
  32.             }
  33.             ch /= 10;
  34.         }    
  35.         return result;
  36.     }
  37.     static int g(int ch)
  38.     {
  39.         return ch < 10 ? ch : g(f(ch));
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement