Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class Program
- {
- static void Main()
- {
- int sum = int.Parse(Console.ReadLine());
- int diff = int.Parse(Console.ReadLine());
- bool hasHyvanNumers = false;
- for (int i = 555; i <= 999; i++)
- {
- int abc = i;
- int def = abc + diff;
- int ghi = def + diff;
- if (ghi > 999) break;
- string allNums = "" + abc + def + ghi;
- if (allNums.Contains("0") || allNums.Contains("1") || allNums.Contains("2") || allNums.Contains("3") || allNums.Contains("4")) continue;
- int totalSum = allNums.Sum(t => Convert.ToInt32(Convert.ToString(t)));
- if (totalSum == sum)
- {
- Console.WriteLine(allNums);
- hasHyvanNumers = true;
- }
- }
- if (!hasHyvanNumers) Console.WriteLine("No");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement