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 ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int sum = Convert.ToInt32(Console.ReadLine());
- int diff = Convert.ToInt32(Console.ReadLine());
- bool isMagic = false;
- 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++)
- {
- int num1 = 100 * (a) + 10 * (b) + c;
- int num2 = 100 * (d) + 10 * (e) + f;
- int num3 = 100 * (g) + 10 * (h) + i;
- int sum1 = a + b + c + d + e + f + g + h + i;
- if (sum1 == sum && num3 - num2 == diff && num2 - num1 == diff && num1<num2 && num2<num3)
- {
- isMagic = true;
- Console.Write(num1);
- Console.Write(num2);
- Console.WriteLine(num3);
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- if (isMagic != true)
- {
- Console.WriteLine("No");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement