PKU 1188 Gleaming the Cubes
http://poj.org/problem?id=1188
全ての立方体が重なりあっている領域の大きさを求めろというような問題。
空になる場合に注意して書く。
簡単そうなのに、解いている人が少ないいのが謎。
int n; void solve(){ ll x,ux,y,uy,z,uz; ll le; cin>>x>>y>>z>>le; ux=x+le; uy=y+le; uz=z+le; rep(i,n-1){ ll tx,ty,tz; cin>>tx>>ty>>tz>>le; x=max(tx,x); y=max(ty,y); z=max(tz,z); ux=min(tx+le,ux); uy=min(ty+le,uy); uz=min(tz+le,uz); } if(ux<x || uy<y || uz<z)cout<<0<<endl; else cout<<(ux-x)*(uy-y)*(uz-z)<<endl; } main(){ while(cin>>n,n) solve(); }