4 条题解
-
3
#include #include #include #include using namespace std; int x,y,b,c,d,m,n,s; struct chuang { int l,r,f,t; }a[99]; int main() { int lmax,rmax,fmax,tmax; scanf("%d%d%d%d",&a[1].l,&a[1].r,&a[1].f,&a[1].t); scanf("%d%d%d%d",&a[2].l,&a[2].r,&a[2].f,&a[2].t); lmax=a[1].l>a[2].l?a[1].l:a[2].l; rmax=a[1].ra[2].r?a[1].r:a[2].r; fmax=a[1].fa[2].f?a[1].f:a[2].f; tmax=a[1].t<a[2].t?a[1].t:a[2].t; if(lmax<rmax&&fmax<tmax) { printf("%d",(rmax-lmax)*(tmax-fmax)); } else printf("0"); return 0; }
-
1
#include<algorithm> using namespace std; int z1,y1,s1,x1; struct c { int z,y,s,x; }a[99]; int main() { cin>>a[1].z>>a[1].y>>a[1].s>>a[1].x; cin>>a[2].z>>a[2].y>>a[2].s>>a[2].x; if(a[1].z>a[2].z) z1=a[1].z; else z1=a[2].z; if(a[1].y<a[2].y) y1=a[1].y; else y1=a[2].y; if(a[1].s>a[2].s) s1=a[1].s; else s1=a[2].s; if(a[1].x<a[2].x) x1=a[1].x; else x1=a[2].x; if(z1<y1&&s1<x1) cout<<(y1-z1)*(x1-s1); else cout<<0; return 0; }
-
0
using namespace std; struct twindow{ int left,right,top,bottom; }; twindow wina,winb,tmp; twindow indata(){ twindow tmp; cin >> tmp.left >> tmp.right >> tmp.top >> tmp.bottom; return tmp; } int main(){ wina = indata(); winb = indata(); tmp.left = max(wina.left,winb.left); tmp.right = min(wina.right,winb.right); tmp.top = max(wina.top,winb.top); tmp.bottom = min(wina.bottom,winb.bottom); int s = (tmp.right - tmp.left) * (tmp.bottom - tmp.top); if((tmp.right <= tmp.left) || (tmp.bottom <= tmp.top)) s = 0; cout << s << endl; return 0; }
-
-4
#include #include using namespace std; struct zuobiao {int zuo,you,shang,xia; }a[3]; int jisuan(int a1,int a2,int a3,int a4,int b1,int b2,int b3,int b4) { int heng,zong; heng=(a2-a1+b2-b1-abs(a1-b1)-abs(a2-b2))/2; zong=(a4-a3+b4-b3-abs(a3-b3)-abs(a4-b4))/2; return heng*zong; } int main() { int i; for(i=1;i<=2;i++) { cin>>a[i].zuo>>a[i].you>>a[i].shang>>a[i].xia; } if(((a[1].zuo<=a[2].you)&&(a[1].you>=a[2].zuo))&&((a[1].xia>=a[2].shang)&&(a[1].shang<=a[2].xia))) cout<<jisuan(a[1].zuo,a[1].you,a[1].shang,a[1].xia,a[2].zuo,a[2].you,a[2].shang,a[2].xia); else cout<<0; } 数学方法 相交=(1长+2长-左(上)差-右(下)差)/2
- 1
信息
- ID
- 387
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 5
- 标签
- 递交数
- 126
- 已通过
- 44
- 上传者