|  | 
|  | 
| вернуться в форум | AAaaaaa(????)1009 using System;using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 class Program
 {
 static void Main(string[] args)
 {
 int k;
 int n;
 do
 {
 do{
 n = int.Parse(Console.ReadLine());
 } while (!(n >= 2));
 do
 {
 k = int.Parse(Console.ReadLine());
 } while (!(k >= 2 && k <= 10));
 } while (!(n + k <= 18));
 int start = (int)Math.Pow(10, n - 1);
 int end = 0;
 int check = start;
 int BigCount = 0;
 for (int i = n - 1; i >= 0; i--)
 end += (k - 1) * (int)Math.Pow(10, i);
 int h = end - start + 1;
 int o = 0;
 for (int l = 0; l < n; l++)
 {
 o += h % 10 * (int)Math.Pow(k, l);
 h = h / 10;
 }
 for (int i = 0; i < o; i++)
 {
 int count = 0;
 double p = check;
 for (int j = 0; j < n / 2; j++)
 {
 if ((p % 10 + p / 10 % 10) > 0) count++;
 p = p / 100;
 }
 if (count != 0) BigCount++;
 check++;
 count = 0;
 p = check;
 int r = 0;
 int m = 0;
 for (int l = 0; l < n; l++)
 {
 if (p % 10 == k)
 {
 count++;
 m += (10 - k) * (int)Math.Pow(10, l);
 r = 10 - k;
 }
 p += r;
 p = (int)p / 10;
 }
 check += m;
 }
 
 Console.Write(BigCount);
 }
 }
 Норм решение?
 
 Edited by author 16.01.2017 04:29
 
 Edited by author 16.01.2017 04:30
 | 
 | 
|