HDU 1866 A + B forever! 有坑,注意题意!!!
来源:互联网 发布:js文件怎么编写使用 编辑:程序博客网 时间:2024/06/03 23:28
A + B forever!
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1080 Accepted Submission(s): 232
Problem Description
As always, A + B is the necessary problem of this warming-up contest. But the patterns and contents are different from the previous ones. Now I come up with a new “A + B” problem for you, the top coders of HDU.
As we say, the addition defined between two rectangles is the sum of their area . And you just have to tell me the ultimate area if there are a few rectangles.
Isn’t it a piece of cake for you? Come on! Capture the bright “accepted” for yourself.
As we say, the addition defined between two rectangles is the sum of their area . And you just have to tell me the ultimate area if there are a few rectangles.
Isn’t it a piece of cake for you? Come on! Capture the bright “accepted” for yourself.
Input
There come a lot of cases. In each case, there is only a string in one line. There are four integers, such as “(x1,y1,x2,y2)”, describing the coordinates of the rectangle, with two brackets distinguishing other rectangle(s) from the string. There lies a plus symbol between every two rectangles. Blanks separating the integers and the interpunctions are added into the strings arbitrarily.The length of the string doesn’t exceed 500.
0<=x1,x2<=1000,0<=y1,y2<=1000.
0<=x1,x2<=1000,0<=y1,y2<=1000.
Output
For each case, you just need to print the area for this “A+B” problem. The results will not exceed the limit of the 32-signed integer.
Sample Input
(1,1,2,2)+(3,3,4,4)(1,1,3,3)+(2,2,4,4)+(5,5,6,6)
Sample Output
28
Author
Wang Ye
Source
2008杭电集训队选拔赛——热身赛
Recommend
lcy | We have carefully selected several similar problems for you: 1867 1869 1211 1870 1753
(1,/1,3,;; 3) / + ,/ (2, 2,4,4) + , ( %6 ,!!6,5,5)输出8
#include<stdio.h>#include<string.h>int m[1005][1005];int max(int a,int b) { return a>b?a:b; }int min(int a,int b) { return a<b?a:b; }int main(){char s[505],ch[505];int i,j,k,x1,y1,x2,y2,xmin,xmax,ymin,ymax,len,c,p;while(gets(s)){len=strlen(s);memset(m,0,sizeof(m)); memset(ch,0,sizeof(ch));c=k=p=0;for(i=0;i<len;i++){if(s[i]>='0'&&s[i]<='9'){ch[k++]=s[i];if(!(s[i+1]>='0'&&s[i+1]<='9')) p++,ch[k++]=' ';}if(p==4){ch[k++]='+';ch[k++]=' ';p=0;}}ch[k]='\0';len=strlen(ch);for(k=0;k<len;k++){if(k==0 || ch[k-1]=='+'){sscanf(ch+k,"%d %d %d %d",&x1,&y1,&x2,&y2);xmin=min(x1,x2); xmax=max(x1,x2);ymin=min(y1,y2); ymax=max(y1,y2);for(i=xmin;i<xmax;i++)for(j=ymin;j<ymax;j++)if(!m[i][j]) {c++; m[i][j]=1;}}}printf("%d\n",c);}return 0;}
0 0
- HDU 1866 A + B forever! 有坑,注意题意!!!
- hdu 1866 A + B forever!
- HDU 1866 A + B forever!
- HDU 1866 A + B forever!
- HDU- 2054 A == B ?(一定要注意陷阱)
- HDU——1393Weird Clock(水题,注意题意)
- 【HDU】3787 A+B-->有逗号版(其实是手读)
- HDU 1017 A Mathematical Curiosity【看懂题意+穷举法】
- 【hdu】1698 just a hook 中文题意&题解
- hdu 5038 水题 但是题意坑
- YT14-HDU-满足(a^2+b^2 +m)/(ab)的(a,b)有多少
- A Forever Friend
- A Forever Friend
- A Forever Friend
- A forever friend
- A forever friend!
- A forever friend
- A Forever Friend
- 20140612_Time-Series Data Mining
- 使用g++编译C/C++程序,链接时出现undefined reference to错误
- 结构-05. 有理数均值(20)
- 黑马程序员-随笔
- 【经验小谈】百度定位api使用 百度定位demo 百度地图快速定位 百度地图获取当前位置 获取自己的位置 百度定位示例
- HDU 1866 A + B forever! 有坑,注意题意!!!
- 黑马程序员-随笔2
- org.springframework.beans.factory.BeanNotOfRequiredTypeException:
- 16 oj 矩阵求和 重载运算符
- 结构-06. 复数四则运算(15)
- 在Ubuntu10.04上部署BigBlueButton
- Uboot2014.04移植到S3C2440(一)--编译过程
- C语言柔性数组
- 奋战一下午写的一个简单计算器