Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- int sum = int.Parse(Console.ReadLine());
- int dif = int.Parse(Console.ReadLine());
- int digSum = 0;
- int abc = 0;
- int def = 0;
- int ghi = 0;
- bool noResult = true;
- for (int a = 1; a < 8; a++)
- {
- for (int b = 1; b < 8; b++)
- {
- for (int c = 1; c < 8; c++)
- {
- for (int d = 1; d < 8; d++)
- {
- for (int e = 1; e < 8; e++)
- {
- for (int f = 1; f < 8; f++)
- {
- for (int g = 1; g < 8; g++)
- {
- for (int h = 1; h < 8; h++)
- {
- for (int i = 1; i < 8; i++)
- {
- digSum = a + b + c + d + e + f + g + h + i;
- if (digSum == sum)
- {
- abc = a * 100 + b * 10 + c;
- def = d * 100 + e * 10 + f;
- ghi = g * 100 + h * 10 + i;
- if ((abc <= def) && (def - abc == ghi - def) && (def - abc == dif))
- {
- Console.WriteLine("{0}{1}{2}", abc, def, ghi);
- noResult = false;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if (noResult)
- {
- Console.WriteLine("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement