Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace NineDigitNumbers
- {
- class NineDigitNumbers
- {
- static void Main(string[] args)
- {
- uint sum = uint.Parse(Console.ReadLine());
- uint diff = uint.Parse(Console.ReadLine());
- int flag = 0;
- for (int a = 1; a <= 7; a++)
- {
- for (int b = 1; b <= 7; b++)
- {
- for (int c = 1; c <= 7; c++)
- {
- for (int d = 1; d <= 7; d++)
- {
- for (int e = 1; e <= 7; e++)
- {
- for (int f = 1; f <= 7; f++)
- {
- for (int g = 1; g <= 7; g++)
- {
- for (int h = 1; h <= 7; h++)
- {
- for (int i = 1; i <= 7; i++)
- {
- if (a + b + c + d + e + f + g + h + i == sum)
- {
- int first = int.Parse(a.ToString() + b.ToString() + c.ToString());
- int second = int.Parse(d.ToString() + e.ToString() + f.ToString());
- int third = int.Parse(g.ToString() + h.ToString() + i.ToString());
- if (third - second == diff && second - first == diff)
- {
- Console.WriteLine("{0}{1}{2}{3}{4}{5}{6}{7}{8}", a, b, c, d, e, f, g, h, i);
- flag++;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if (flag == 0)
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement