[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
在一家重要的研究机构工作,小希参与了一项重要的试验:使用激光装置融化巧克力。
该装置有包含 n×m 个单元的一个长方形区域以及一个机械臂组成,每个单元为一个 1×1
的小方块。机械臂上有两束激光垂直射向其表面,任何时候激光束都会射向两个单元的中心。由于两个激光束发射装置装在同一个机械臂上,故移动是同步的,也就是说,移动都在同一方向上。
已知的事实为:
*
*
开始时整个区域被大小为 n×m 的巧克力块覆盖,两束激光均处于区域上方且已激活
*
只有被激光射向单元的巧克力将融化,其他单元内的不受影响
*
机械臂的任何移动必须平行于区域的边缘,每次移动后激光都会同时射向两个单元的中心
*
任何时候激光都只能射向本区域
给出 n 和 m,表示区域的大小,行号从上往下从 1 到 n,列号从左到右为 1 到 m。
给出两束激光最开始时的位置 (x1, y1) 和 (x2, y2),其中 x1、x2 为行号,y1、y2 为列号。
请找出这个区域内有多少单元的巧克力不能被融化。
#include<iostream> #include<stdlib.h> #include<algorithm> using namespace std;
int main() { int t,n,m,x1,y1,x2,y2,x0,y0,xm,ym; cin>>t; for(int i=0;i<t;i++) {
int sum=0; cin>>n>>m>>x1>>y1>>x2>>y2; x0=abs(x1-x2); y0=abs(y1-y2); if(y0==0) {
if(x0<=n/2) {cout<<0<<endl;} if(x0>n/2) { sum=m*n-2*(n-max(x1,x2)+1)*m;
cout<<sum<<endl; } } else if(x0==0) { if(y0<=m/2) {cout<<0<<endl;} if(y0>m/2) {
sum=m*n-2*(m-max(y1,y2)+1)*n; cout<<sum<<endl; } } else { if(x0<=n/2&&y0<=m/2)
{ sum=2*x0*y0; cout<<sum<<endl; } if(x0>n/2&&y0<=m/2) {
sum=n*m-2*(n-max(x1,x2)+min(x1,x2))*(m-max(y1,y2)+min(y1,y2)); cout<<sum<<endl;
} if(x0<=n/2&&y0>m/2) {
sum=n*m-2*(n-max(x1,x2)+min(x1,x2))*(m-max(y1,y2)+min(y1,y2)); cout<<sum<<endl;
} if(x0>n/2&&y0>m/2) {
sum=n*m-2*(n-max(x1,x2)+min(x1,x2))*(m-max(y1,y2)+min(y1,y2)); cout<<sum<<endl;
} } } }