Development Forum
글 수 21
import java.io.*;
import java.util.Scanner;
public class LoveMinwoo {
public static void main(String[] args){
//args = new String[1];
//args[0] = "testInput.txt";
FileInputStream inputFile = null;
int[][] arr = new int[2001][2001];
try
{
inputFile = new FileInputStream(args[0]);
Scanner input = new Scanner(inputFile);
int size = input.nextInt();
for(int i = 0; i < size; i++)
{
int x = input.nextInt() + 1000;
int y = input.nextInt() + 1000;
int width = input.nextInt();
int height = input.nextInt();
for (int j = 0; j < width; j++)
for (int k = 0; k < height; k++)
{
arr[x+j][y+k]++;
}
}
} catch (Exception e) {
System.out.println("입력값 똑바로 줘");
System.out.println(e.getStackTrace());
System.out.println(e.getMessage());
System.exit(0);
}
int overlap_area = 0;
for(int i = 0; i < 2000; i++)
for(int j = 0; j < 2000; j++)
if(arr[i][j] > 1)
overlap_area++;
String output = "Overlap area : " + overlap_area;
System.out.println(output);
}
}
끝까지 아무도 안풀길래요.
import java.util.Scanner;
public class LoveMinwoo {
public static void main(String[] args){
//args = new String[1];
//args[0] = "testInput.txt";
FileInputStream inputFile = null;
int[][] arr = new int[2001][2001];
try
{
inputFile = new FileInputStream(args[0]);
Scanner input = new Scanner(inputFile);
int size = input.nextInt();
for(int i = 0; i < size; i++)
{
int x = input.nextInt() + 1000;
int y = input.nextInt() + 1000;
int width = input.nextInt();
int height = input.nextInt();
for (int j = 0; j < width; j++)
for (int k = 0; k < height; k++)
{
arr[x+j][y+k]++;
}
}
} catch (Exception e) {
System.out.println("입력값 똑바로 줘");
System.out.println(e.getStackTrace());
System.out.println(e.getMessage());
System.exit(0);
}
int overlap_area = 0;
for(int i = 0; i < 2000; i++)
for(int j = 0; j < 2000; j++)
if(arr[i][j] > 1)
overlap_area++;
String output = "Overlap area : " + overlap_area;
System.out.println(output);
}
}
끝까지 아무도 안풀길래요.

int y = input.nextInt() + 1000;
int width = input.nextInt();
int height = input.nextInt();
아이고야 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
전 4개 다 1000을 더해놓고 왜안되지 하고 고민하다 못풀었지 말입니다 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ