B Equal Rectangles

题意:

给你4*n个数,让你判断能不能用这个4*n个数为边凑成n个矩形,使的每个矩形面积相等

题解:

原本是想着用二分来找出来那个最终的面积,但是仔细想一想,那个面积只能是给出的4*n个数中的最小值和最大值的乘积,如果这两个长度不凑成一个矩形,那么肯定全部矩形的面积会出现不一致的

代码:

 1 //The idea was to use dichotomies to find that area, and then use that area to figure it out, but it's more complicated than that
2 //If you don't use the smallest and largest as the two sides of a rectangle, there will always be an area larger than that
3 #include <stdio.h>
4 #include <algorithm>
5 #include <iostream>
6 #include <string.h>
7 using namespace std;
8 const int maxn = 405;
9 typedef long long ll;
10 int v[maxn],w[maxn];
11 int main()
12 {
13 int t;
14 scanf("%d",&t);
15 while(t--)
16 {
17 int n;
18 scanf("%d",&n);
19 for(int i=1;i<=4*n;++i)
20 {
21 scanf("%d",&v[i]);
22 }
23 sort(v+1,v+1+4*n);
24 int x=v[1]*v[4*n],flag=1;
25 for(int i=2;i<=2*n;++i)
26 {
27 if(v[i]*v[4*n-i+1]!=x)
28 {
29 flag=0;
30 break;
31 }
32 }
33 for(int i=2;i<=4*n;i+=2)
34 {
35 if(v[i]!=v[i-1])
36 {
37 flag=0;
38 break;
39 }
40 }
41 if(flag) printf("YES\n");
42 else printf("NO\n");
43 }
44 return 0;
45 }

C. Common Divisors

题意:

给你n个数,让你找出来这n个数的公因数有多少个

题解:

肯定不能暴力for循环找,一个数的公因数的因数也是这个数的因数,那么我们就可以找出来这n个数的最大公共因数,然后再在这个因数里面找因数

代码:

 1 #include <bits/stdc++.h>
2
3 #define ll long long
4
5 #define sc scanf
6
7 #define pr printf
8
9 using namespace std;
10
11 ll gcd(ll a, ll b)
12
13 {
14
15 return b == 0 ? a : gcd(b, a % b);
16
17 }
18
19 int main()
20
21 {
22
23 int n;
24
25 scanf("%d", &n);
26
27 ll t1, t2;
28
29 sc("%lld", &t1);
30
31 for (int i = 1; i < n; i++)
32
33 {
34
35 sc("%lld", &t2);
36
37 t1 = gcd(t1, t2);
38
39 }
40
41 ll qq = sqrt(t1);
42
43 ll ans = 0;
44
45 for (ll i = 1; i <= qq; i++)
46
47 {
48
49 if (t1 % i == 0)
50
51 {
52
53 ans++;
54
55 if (t1 / i != i)
56
57 ans++;
58
59 }
60
61 }
62
63 printf("%lld", ans);
64
65 }

Codeforces Round #579 (Div. 3) B Equal Rectangles、C. Common Divisors的更多相关文章

  1. Codeforces Round #579 (Div. 3)

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

  2. Codeforces Round #433 (Div. 2)【A、B、C、D题】

    题目链接:Codeforces Round #433 (Div. 2) codeforces 854 A. Fraction[水] 题意:已知分子与分母的和,求分子小于分母的 最大的最简分数. #in ...

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

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

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

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

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

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

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

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

  7. Codeforces Round #371 (Div. 2) D. Searching Rectangles 交互题 二分

    D. Searching Rectangles 题目连接: http://codeforces.com/contest/714/problem/D Description Filya just lea ...

  8. Codeforces Round #486 (Div. 3)-C. Equal Sums

    C. Equal Sums time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  9. Codeforces Round #219 (Div. 2) D. Counting Rectangles is Fun 四维前缀和

    D. Counting Rectangles is Fun time limit per test 4 seconds memory limit per test 256 megabytes inpu ...

随机推荐

  1. 九:APP及其他资产

    APP提取一键反编译提取 APP抓数据包进行工具配合 各种第三方应用相关探针技术 各种服务器接口相关探针技术 APP提取及抓包及后续配合 某APK一键提取反编译 利用burp历史抓更多URL 某IP无 ...

  2. PC个人隐私保护小方法

    前言 近期爆出了腾讯读取用户浏览器浏览记录的消息.话不过说直接上图,懂的自然懂. 网上也有详细的分析文章,不管它读取后用来做什么,在你不知情的情况下读取了你的浏览器浏览记录,你说气不气. 虽然在整体大 ...

  3. (十四)json、pickle与shelve模块

    任何语言,都有自己的数据类型,那么不同的语言怎么找到一个通用的标准? 比如,后端用Python写的,前端是js,那么后端如果传一个dic字典给前端,前端肯定不认. 所以就有了序列化这个概念. 什么是序 ...

  4. 解压rpm文件

    rpm2cpio zabbix-2.2.2-0.el6.zbx.src.rpm |cpio -div

  5. 【MySQL】Last_SQL_Errno: 1594Relay log read failure: Could not parse relay log event entry...问题总结处理

    备库报错: Last_SQL_Errno: 1594 Last_SQL_Error: Relay log read failure: Could not parse relay log event e ...

  6. JavaScript中的事件委托机制跟深浅拷贝

    今天聊下JavaScript中的事件委托跟深浅拷贝 事件委托 首先呢,介绍一下事件绑定 //方法一:通过onclick <button onclick="clickEvent()&qu ...

  7. 分布式系统:分布式任务调度xxl-job较深入使用

    目录 系统关键概念介绍 执行器 任务 任务配置项描述 阻塞策略 路由策略 日志问题 客户端日志 服务端日志 框架目前发现的缺点以及存在的问题 xxl-job是一个分布式定时任务调度框架,功能强大,底层 ...

  8. three.js cannon.js物理引擎之约束

    今天郭先生继续说cannon.js,主演内容就是点对点约束和2D坐标转3D坐标.仍然以一个案例为例,场景由一个地面.若干网格组成的约束体和一些拥有初速度的球体组成,如下图.线案例请点击博客原文. 下面 ...

  9. pscp 从win10远程传输文件到centos7,多个虚拟机之间传文件

    一.将下载的pscp.exe拷贝到C:\Windows\System32 上传文件 win10 --> linux1 C:\Users\xy>pscp C:\BaiduNetdiskDow ...

  10. Django-html文件实例

    1.实例1,登陆界面 <!DOCTYPE html> <head> <meta http-equiv="content-type" content=& ...