Advertisement
Guest User

GenerateRectangles

a guest
Apr 3rd, 2016
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. namespace GenerateRectangles
  2. {
  3.     using System;
  4.  
  5.     public class GenerateRectangles
  6.     {
  7.         public static void Main()
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int m = int.Parse(Console.ReadLine());
  11.  
  12.             bool found = false;
  13.  
  14.             for (int i1 = -n; i1 <= 0; i1++)
  15.             {
  16.                 for (int i2 = n; i2 >= 0; i2--)
  17.                 {
  18.                     for (int i3 = -n; i3 <= 0; i3++)
  19.                     {
  20.                         for (int i4 = n; i4 >= 0; i4--)
  21.                         {
  22.                             int sideOne = Math.Abs(i1) + Math.Abs(i2);
  23.                             int sideTwo = Math.Abs(i3) + Math.Abs(i4);
  24.  
  25.                             if (sideOne * sideTwo >= m)
  26.                             {
  27.                                 Console.WriteLine("({0}, {1}) ({2}, {3}) -> {4}", i1, i3, i2, i4, sideOne * sideTwo);
  28.                                 found = true;  
  29.                             }
  30.                         }
  31.                     }
  32.                 }
  33.             }
  34.  
  35.             if (!found)
  36.             {
  37.                 Console.WriteLine("No");
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement