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 Exam04
- {
- class Exam04
- {
- static void Main()
- {
- int sum = int.Parse(Console.ReadLine());
- int diff = int.Parse(Console.ReadLine());
- bool flag = false;
- for (int i = 555; i <= 999; i++)
- {
- int secondNumber = i + diff;
- int thirdNumber = secondNumber + diff;
- if (i%10<5||(i/10)%10<5||(i/100)%10<5||secondNumber%10<5||(secondNumber/10)%10<5||(secondNumber/100)%10<5||thirdNumber%10<5||(thirdNumber/10)%10<5||(thirdNumber/100)%10<5)
- {
- continue;
- }
- if (secondNumber>999||thirdNumber>999)
- {
- break;
- }
- int newSum = 0;
- int firstCopy = i;
- newSum += firstCopy % 10;
- firstCopy /= 10;
- newSum += firstCopy % 10;
- firstCopy /= 10;
- newSum += firstCopy % 10;
- int secondCopy = secondNumber;
- newSum += secondCopy % 10;
- secondCopy /= 10;
- newSum += secondCopy % 10;
- secondCopy /= 10;
- newSum += secondCopy % 10;
- int thirdCopy = thirdNumber;
- newSum += thirdCopy % 10;
- thirdCopy /= 10;
- newSum += thirdCopy % 10;
- thirdCopy /= 10;
- newSum += thirdCopy % 10;
- if(sum==newSum)
- {
- Console.Write(i);
- Console.Write(secondNumber);
- Console.Write(thirdNumber);
- Console.WriteLine();
- flag = true;
- }
- }
- if (!flag)
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement