Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_101_January_2016 - created by borkins on 2017-05-03.
- */
- import java.util.Scanner;
- public class _12_GenerateRectangles
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int n = Integer.parseInt(console.nextLine());
- int m = Integer.parseInt(console.nextLine());
- int count = 0;
- for (int x1 = -n; x1 < n; x1++)
- {
- for (int y1 = -n; y1 < n; y1++)
- {
- for (int x2 = x1 + 1; x2 <= n; x2++)
- {
- for (int y2 = y1 + 1; y2 <= n; y2++)
- {
- int a = Math.abs(x2 - x1);
- int b = Math.abs(y2 - y1);
- if (a * b >= m) {
- System.out.printf("(%d, %d) (%d, %d) -> %d%n",
- x1, y1, x2, y2, (a * b));
- count++;
- }
- }
- }
- }
- }
- if (count == 0) System.out.println("No");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment