Advertisement
AlexJC

Generate Rectangles

Aug 27th, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Generate_Rectangles
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int input1 = int.Parse(Console.ReadLine());
  14. int input2 = int.Parse(Console.ReadLine());
  15.  
  16. if ((4 * input1 * input1) < input2)
  17. {
  18. Console.WriteLine("No");
  19. }
  20. else
  21. {
  22. for (int left = -input1; left <= input1; left++)
  23. {
  24. for (int top = -input1; top <= input1; top++)
  25. {
  26. for (int right = -input1; right <= input1; right++)
  27. {
  28. if (right > left)
  29. {
  30. for (int bottom = -input1; bottom <= input1; bottom++)
  31. {
  32. if (bottom > top)
  33. {
  34. int side1 = left - right;
  35. int side2 = top - bottom;
  36. int area = side1 * side2;
  37. if (area >= input2)
  38. {
  39. Console.WriteLine("({0}, {1}) ({2}, {3}) -> {4}", left, top, right, bottom, area);
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement