UVA - 1587 Box 麻烦
来源:互联网 发布:学外贸英语的软件 编辑:程序博客网 时间:2024/05/02 00:16
Ivan works at a factory that produces heavy machinery. He has a simple job -- he knocks up wooden boxes of different sizes to pack machinery for delivery to the customers. Each box is a rectangular parallelepiped. Ivan uses six rectangular wooden pallets to make a box. Each pallet is used for one side of the box.Joe delivers pallets for Ivan. Joe is not very smart and often makes mistakes -- he brings Ivan pallets that do not fit together to make a box. But Joe does not trust Ivan. It always takes a lot of time to explain Joe that he has made a mistake. Fortunately, Joe adores everything related to computers and sincerely believes that computers never make mistakes. Ivan has decided to use this for his own advantage. Ivan asks you to write a program that given sizes of six rectangular pallets tells whether it is possible to make a box out of them.
Input
Input file contains several test cases. Each of them consists of six lines. Each line describes one pallet and contains two integer numbers w and h ( 1w, h10 000) -- width and height of the pallet in millimeters respectively.Output
For each test case, print one output line. Write a single word `POSSIBLE' to the output file if it is possible to make a box using six given pallets for its sides. Write a single word `IMPOSSIBLE' if it is not possible to do so.Sample Input
1345 25842584 6832584 1345683 1345683 13452584 6831234 45671234 45674567 43214322 45674321 12344321 1234
Sample Output
POSSIBLEIMPOSSIBLE#include <cstdio>#include <cmath>#include <cstdlib>#include <cstring>int main(){ double a[3],b[3],c[3],x,y; int i,sign; while(~scanf("%lf%lf",&x,&y)) { sign=0; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); memset(c,0,sizeof(c)); a[1]=x,a[2]=y,a[0]=1; for(i=1;i<6;i++) { scanf("%lf%lf",&x,&y); if((x==a[1]&&y==a[2])||(x==a[2]&&y==a[1])) a[0]++; else { if(b[1]<=1e-6&&b[2]<=1e-6) b[1]=x,b[2]=y,b[0]=1; else { if((x==b[1]&&y==b[2])||(x==b[2]&&y==b[1])) b[0]++; else { if(c[1]<=1e-6&&c[2]<=1e-6) c[1]=x,c[2]=y,c[0]=1; else { if((x==c[1]&&y==c[2])||(x==c[2]&&y==c[1])) c[0]++; else { sign=1; } } } } } } if(sign) printf("IMPOSSIBLE\n"); else { if(a[0]==6&&fabs(a[1]-a[2])<1e-6) printf("POSSIBLE\n"); else if(b[0]==4&&fabs(a[1]-a[2])<1e-6||a[0]==4&&fabs(b[1]-b[2])<1e-6) printf("POSSIBLE\n"); else if(a[0]==2&&b[0]==2&&c[0]==2) { if(fabs(a[1]-b[1])<1e-6||fabs(a[2]-b[2])<1e-6||fabs(a[2]-b[1])<1e-6||fabs(a[1]-b[2])<1e-6) { if(fabs(a[1]-b[1])<1e-6) { if((fabs(a[2]-c[2])<1e-6&&fabs(c[1]-b[2])<1e-6)||(fabs(a[2]-c[1])<1e-6&&fabs(c[2]-b[2])<1e-6)) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n"); } else if(fabs(a[1]-b[2])<1e-6) { if((fabs(a[2]-c[2])<1e-6&&fabs(c[1]-b[1])<1e-6)||(fabs(a[2]-c[1])<1e-6&&fabs(c[2]-b[1])<1e-6)) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n"); } else if(fabs(a[2]-b[1])<1e-6) { if((fabs(a[1]-c[2])<1e-6&&fabs(b[2]-c[1])<1e-6)||(fabs(a[1]-c[1]<1e-6&&fabs(b[2]-c[2])<1e-6))) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n"); } else if(fabs(a[2]-b[2])<1e-6) { if((fabs(a[1]-c[2])<1e-6&&fabs(b[1]-c[1])<1e-6)||(fabs(a[1]-c[1]<1e-6&&fabs(b[1]-c[2])<1e-6))) printf("POSSIBLE\n"); else printf("IMPOSSIBLE\n"); } } else printf("IMPOSSIBLE\n"); } else printf("IMPOSSIBLE\n"); } } return 0;}
0 0
- UVA - 1587 Box 麻烦
- uva 1587 - Box
- uva 1587 - Box
- UVa 1587 - Box
- UVa 1587 - Box
- UVa 1587 Box
- Uva-1587-Box-AC
- UVA - 1587 Box
- UVa 1587 Box
- Box UVa 1587
- UVa 1587 - Box
- UVa 1587 - Box
- UVa-1587 - Box
- UVa 1587 Box
- Uva - 1587 - Box
- UVA - 1587 Box
- UVA 1587 BOX
- UVa 1587 BOX
- BASH TEST 测试操作
- MPI初探(原理与认识)
- Android studio导入eclipse项目且不改变目录结构
- 如何在真机上调试Android应用程序(图文详解)
- [ 生活感悟 ] 岁月静好,现世安稳
- UVA - 1587 Box 麻烦
- 调试利器之tcpdump详解
- arcgis javascript api 学习总结一
- 74cms 骑士人才系统v3.5.1 正式版
- 模拟退火算法
- Oracle中over用法
- 驱动模块Makefile解析
- 因为你
- 推荐11个实用Python库