Question number: | 201409-2 |
Question name: | Drawing |
time limit: | 1.0s |
Memory limit: | 256.0MB |
Problem Description: | Problem Description Drawing a rectangle from (x1, y1) to (x2, y2) on a piece of paper that defines a rectangular coordinate system means to color the area between the abscissa range from x1 to x2 and the ordinate range from y1 to y2 . Input format The first line of input contains an integer n, which represents the number of rectangles to be drawn. Output format Output an integer, indicating how many units of the area are colored. Sample input 2 Sample output 15 Evaluation use case scale and conventions 1<=n<=100, 0<=abscissa, ordinate<=100. |
import java.util.Scanner;
public class 画图201409_2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int len=sc.nextInt();
int[][] a=new int[101][101];
int[] area=new int[4*len+1];
for(int i=1;i<=4*len;i++){
area[i]=sc.nextInt();
}
for(int i=0;i<len;i++){
for(int j=area[4*i+1];j<area[4*i+3];j++){
for(int k=area[4*i+2];k<area[4*i+4];k++){
a[j][k]=1;
}
}
}
int sum=0;
for(int i=0;i<100;i++){
for(int j=0;j<100;j++){
if(a[i][j]!=0){
sum+=1;
}
}
}
System.out.println(sum);
}
}