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的更多相关文章

  1. CF #579 (Div. 3) B.Equal Rectangles

    B.Equal Rectangles time limit per test2 seconds memory limit per test256 megabytes inputstandard inp ...

  2. [贪心]Codeforces Equal Rectangles

    Equal Rectangles time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  3. Codeforces Round #579 (Div. 3) B Equal Rectangles、C. Common Divisors

    B Equal Rectangles 题意: 给你4*n个数,让你判断能不能用这个4*n个数为边凑成n个矩形,使的每个矩形面积相等 题解: 原本是想着用二分来找出来那个最终的面积,但是仔细想一想,那个 ...

  4. codeforces #579(div3)

    codeforces #579(div3) A. Circle of Students 题意: 给定一个n个学生的编号,学生编号1~n,如果他们能够在不改变顺序的情况下按编号(无论是正序还是逆序,但不 ...

  5. Codeforces Round #579 (Div. 3)

    Codeforces Round #579 (Div. 3) 传送门 A. Circle of Students 这题我是直接把正序.逆序的两种放在数组里面直接判断. Code #include &l ...

  6. 【cf比赛练习记录】Codeforces Round #579 (Div. 3)

    思考之后再看题解,是与别人灵魂之间的沟通与碰撞 A. Circle of Students 题意 给出n个数,问它们向左或者向右是否都能成一个环.比如样例5是从1开始向左绕了一圈 [3, 2, 1, ...

  7. Codeforces Round #579 (Div. 3) 套题 题解

    A. Circle of Students      题目:https://codeforces.com/contest/1203/problem/A 题意:一堆人坐成一个环,问能否按逆时针或者顺时针 ...

  8. Codeforces Round #579 (Div. 3) 题解

    比赛链接:https://codeforc.es/contest/1203/ A. Circle of Students 题意:\(T\)组询问,每组询问给出\(n\)个数字,问这\(n\)个数字能否 ...

  9. White Rectangles[HDU1510]

    White Rectangles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

随机推荐

  1. mysql数据库负载均衡高可用之主从、主主备份,实时同步

    一:MySQL Replication 什么是MySQL Replication Replication可以实现将数据从一台数据库服务器(master)复制到一或多台数据库服务器(slave) 默认情 ...

  2. [转帖]怎样选择(FC-SAN)光纤通道(存储)交换机

    怎样选择(FC-SAN)光纤通道(存储)交换机 https://blog.csdn.net/sinat_30171789/article/details/50510936 交换机的种类非常多...   ...

  3. kubeadm搭建K8s集群及Pod初体验

    基于Kubeadm 搭建K8s集群: 通过上一篇博客,我们已经基本了解了 k8s 的基本概念,也许你现在还是有些模糊,说真的我也是很模糊的.只有不断地操作去熟练,强化自己对他的认知,才能提升境界. 我 ...

  4. Let's encrypt 通配域名DNS验证方式的证书自动更新

    通配符域名不同于一般的单域名证书. 为了解决之前一篇短文中通配域名通过DNS方式验证的证书自动更新问题. 需要使用到第三方域名提供商的API, 用于自动添加域名的TXT记录, 实现自动验证并完成证书更 ...

  5. 异步Promise及Async/Await可能最完整入门攻略

    此文只介绍Async/Await与Promise基础知识与实际用到注意的问题,将通过很多代码实例进行说明,两个实例代码是setDelay和setDelaySecond. tips:本文系原创转自我的博 ...

  6. 学习Golang语言(6):类型--切片

    学习Golang语言(1): Hello World 学习Golang语言(2): 变量 学习Golang语言(3):类型--布尔型和数值类型 学习Golang语言(4):类型--字符串 学习Gola ...

  7. C#多播委托详解

    包含多个方法的委托成为多播委托,调用多播委托,可以按照顺序连续调用多个方法,因此,委托的签名就必须返回void;否则,就只能得到委托调用的最好一个方法的结果 1.多播委托可以用运算符"+&q ...

  8. spark(2)

    1.spark模块 -------------------------------------- (1)Spark Core //核心库 (2)Spark SQL //核心库 (3)Spark Str ...

  9. c++ Socket客户端和服务端示例版本一

    客户端 #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/soc ...

  10. 2019-11-28-win10-uwp-提示-Cannot-find-a-Resource-with-the-Name-Key-找不到资源

    title author date CreateTime categories win10 uwp 提示 Cannot find a Resource with the Name Key 找不到资源 ...