Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace TheSongOfTheWheels
- {
- class Program
- {
- static void Main(string[] args)
- {
- int M = int.Parse(Console.ReadLine());
- int combinationsCount = 0;
- string password = "";
- int sum = 0;
- if ((M >= 4) && (M <= 144))
- {
- for (int first = 1; first <= 9; first++)
- {
- for (int second = 1; second <= 9; second++)
- {
- for (int third = 1; third <= 9; third++)
- {
- for (int fourth = 1; fourth <= 9; fourth++)
- {
- sum = (first * second) + (third * fourth);
- if (first < second && third > fourth && sum == M)
- {
- combinationsCount++;
- Console.Write($"{first}{second}{third}{fourth} ");
- if (combinationsCount == 4)
- {
- password = $"{first}{second}{third}{fourth} ";
- }
- }
- }
- }
- }
- }
- if (combinationsCount >= 4)
- {
- Console.WriteLine();
- Console.WriteLine($"Password: {password}");
- }
- else
- {
- Console.WriteLine("No!");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment