B. Equal Rectangles
给定4*N个数,是否能构成N个矩形
面积均相等
每次取两个大的,两个小的
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sc(x) scanf("%I64d",&x);
#define read(A) for(int i=0;i<4*N;i++) scanf("%I64d",&A[i]);
#define P pair<ll,ll>
ll N;
ll q;
ll A[];
ll st;
int main()
{
sc(q);
while(q--)
{
sc(N);
memset(A,,sizeof A);
for(int i=; i<*N; i++)
{
sc(st);
A[st]++;
} int j=;
bool f=;
ll ans=-,a,b;
for(int i=; i<=j; )
{
if(A[i]>=)
{
A[i]-=;
a=i;
while(j>=i&&A[j]==)
{
j--;
}
// cout<<i<<A[j]<<j<<endl;
if(A[j]>=)
{
A[j]-=;
b=j;
if(ans==-)
{
ans=a*b;
}
else if(ans!=a*b)
{
puts("NO");
f=;
break;
}
}
else if(A[j]==)
{
puts("NO");
// cout<<"QWQ"<<'\n';
f=;
break;
}
else
{
puts("NO");
// cout<<"QWQ"<<'\n';
f=;
break; } }
else if(A[i]==)
{
puts("NO");
f=;
break;
}
else i++;
}
if(!f)puts("YES");
}
B. Equal Rectangles的更多相关文章
- CF #579 (Div. 3) B.Equal Rectangles
B.Equal Rectangles time limit per test2 seconds memory limit per test256 megabytes inputstandard inp ...
- [贪心]Codeforces Equal Rectangles
Equal Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- Codeforces Round #579 (Div. 3) B Equal Rectangles、C. Common Divisors
B Equal Rectangles 题意: 给你4*n个数,让你判断能不能用这个4*n个数为边凑成n个矩形,使的每个矩形面积相等 题解: 原本是想着用二分来找出来那个最终的面积,但是仔细想一想,那个 ...
- codeforces #579(div3)
codeforces #579(div3) A. Circle of Students 题意: 给定一个n个学生的编号,学生编号1~n,如果他们能够在不改变顺序的情况下按编号(无论是正序还是逆序,但不 ...
- Codeforces Round #579 (Div. 3)
Codeforces Round #579 (Div. 3) 传送门 A. Circle of Students 这题我是直接把正序.逆序的两种放在数组里面直接判断. Code #include &l ...
- 【cf比赛练习记录】Codeforces Round #579 (Div. 3)
思考之后再看题解,是与别人灵魂之间的沟通与碰撞 A. Circle of Students 题意 给出n个数,问它们向左或者向右是否都能成一个环.比如样例5是从1开始向左绕了一圈 [3, 2, 1, ...
- Codeforces Round #579 (Div. 3) 套题 题解
A. Circle of Students 题目:https://codeforces.com/contest/1203/problem/A 题意:一堆人坐成一个环,问能否按逆时针或者顺时针 ...
- Codeforces Round #579 (Div. 3) 题解
比赛链接:https://codeforc.es/contest/1203/ A. Circle of Students 题意:\(T\)组询问,每组询问给出\(n\)个数字,问这\(n\)个数字能否 ...
- White Rectangles[HDU1510]
White Rectangles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
随机推荐
- IDEA中解决 git pull 冲突
0.事先准备.1)把远程仓库的README.md内容改写为bbb(原先为aaa). 2)本地仓库的README.md内容改写为ccc(原先也为aaa). 以此来模仿代码冲突. 1.先commit ...
- eclipse中经常用到的修改菜单项
1.编写java程序时,书写一个类之后,要调用此类的某个方法时,点个点,此类的所有方法都会自动出现,然后再选择需要的那个方法即可: 2.鼠标放在一个类上面,关于此类的相关描述就会自动加载出来,要修改的 ...
- 【LGR-063】洛谷11月月赛 I & MtOI2019 Ex Div.2
[MtOI2019]黑蚊子多: 送分向水题,直接模拟即可. #include<iostream> #include<cstdio> #define N 1505 using n ...
- oracle数据库启动报错,不能启动ASM实例
数据库rac启动时报错,日志例如以下,后来使用 Sat Jun 7 06:02:11 2014 GATHER_STATS_JOB encountered errors. Check the tra ...
- django报错处理:对应ip无法登陆与使用bootstrap移动端响应工具,head响应实例
1.报错 Invalid HTTP_HOST header: '192.168.1.100:8000'. You may need to add '192.168.1.100' to ALLOWED_ ...
- 分布式之redis(转发)
为什么写这篇文章? 博主的<分布式之消息队列复习精讲>得到了大家的好评,内心诚惶诚恐,想着再出一篇关于复习精讲的文章.但是还是要说明一下,复习精讲的文章偏面试准备,真正在开发过程中,还是脚 ...
- python 框架
支持异步的 python web 框架 tornado 轻量级 flask 框架 flask中文文档 import base64 import random import io import time ...
- DEV控件的分页控件,实现勾选复选框
/// <summary> /// 单元格的点击事件 /// </summary> /// <param name="sender"></ ...
- ioncube扩展的安装详细图文教程,适合所有新手
有些程序在php环境下运行需要安装ionCube Loader的扩展支持,这里跳过介绍这些东西直接说一下怎么让你的主机环境支持这种扩展,顺利的让你的程序运行起来!这个教程适合用云服务器或者独立服务器的 ...
- GIT服务器项目部署和自动同步
1.1.初始化Git仓库首先我们选定一个目录作为Git仓库,假定是/home/data/share/share.git,在/home/data/目录下输入命令: $ cd /home/data/ $ ...