넒이구하기

조회 수 571 추천 수 0 2009.03.14 13:11:07
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);       
    }
}


끝까지 아무도 안풀길래요.

댓글 '1'

임선용

2009.03.14 19:28:29
*.61.62.131

                int x = input.nextInt() + 1000;
                int y = input.nextInt() + 1000;
                int width = input.nextInt();
                int height = input.nextInt();

아이고야 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ

전 4개 다 1000을 더해놓고 왜안되지 하고 고민하다 못풀었지 말입니다 ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ
문서 첨부 제한 : 0Byte/ 5.00MB
파일 제한 크기 : 5.00MB (허용 확장자 : *.*)
List of Articles
번호 제목 글쓴이 날짜 조회 수
21 기타 RFID질문! [6] 김태현 2010-03-02 570
20 해킹 허..해킹당함... [5] 김재우 2009-09-07 546
19 해킹 심심한 아그들을 위한 리버싱 과제 [2] 김경택님 2009-05-13 617
18 프로그래밍 Google Android [4] 임선용 2009-05-03 664
» 넒이구하기 [1] 펜더 2009-03-14 571
16 네트워크 잘생긴진수의 동아리 지원비 퀴즈 #4 Router Configuration (힌트공개) image [19] 잘생긴진수 2009-03-13 580
15 Modem Signaling-Control [2] 김진수 2006-03-24 909
14 CCW 참고자료 [2] 펜더 2009-03-13 382
13 잘생긴진수의 동아리 지원비 퀴즈 #3 인터넷 검색능력 (취소) [9] 잘생긴진수 2009-03-12 393
12 기타 잘생긴진수의 동아리 지원비 퀴즈 #2 Majority Gate (정답발표) image [17] 잘생긴진수 2009-03-09 389
11 무선 이어폰 (wireless ear buds) [14] 김근모 2009-03-09 433
10 네트워크 잘생긴진수의 동아리 지원비 퀴즈 #1 Ping (정답발표) [12] 잘생긴진수 2009-03-08 372
9 프로그래밍 사라진 집합 원소 찾기 [10] suminb 2009-03-08 376
8 민우 3만원 뺏어오기(?) 프로젝트 재도전 (겹치는 사각형 넓이 구하기) [3] suminb 2009-03-07 378
7 삼만원 도전 image [3] 펜더 2009-03-07 375
6 민우 3만원 뺏어오기(?) 프로젝트 (겹치는 사각형 넓이 구하기) [3] suminb 2009-03-07 386
5 문제2??? image [5] 민우비누a 2009-03-07 376
4 알고리즘 문제.. 정도? [9] 민우비누a 2009-03-06 382
3 정회원전용된기념 싸이취약점.. [5] 김재우 2009-03-02 447
2 1Mb짜리 파일 700개 전송 VS 700Mb짜리 파일 1개 전송 [9] 임선용 2009-02-23 380