Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class GenerateRectangles {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int m = Integer.parseInt(scanner.nextLine());
- int count = 0;
- boolean noPrint = false;
- for (int left = -n; left <= n; left++) {
- for (int top = -n; top <= n; top++) {
- for (int right = left + 1; right <= n; right++) {
- for (int bottom = top + 1; bottom <= n; bottom++) {
- int width = right - left;
- int height = bottom - top;
- int area = width * height;
- if (area >= m) {
- System.out.printf("(%d, %d) (%d, %d) -> %d%n", left, top, right, bottom, area);
- noPrint = true;
- }
- }
- }
- }
- }
- if (!noPrint) {
- System.out.println("No");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment