CodeForces 342A Xenia and Divisors (水题)
题意:给定 n 个数(小于等于7),让你把它分成 m 组,每组有三个数,且满足,a < b < c,并且 a 能整除 b,b 能整除 c。
析:对于这个题,因为题目说了是不大于7的,那么一想不就三组数么,124,136,126.就这三组,然后确定每一组的数量,首先只有第二组有3,那么第二组的数量就确定了,
然后再看剩下的两组,只有第一组有4,那么第一组也就确定,然后剩下的就是第三组,当然第三组只有6.
代码如下:
#include <bits/stdc++.h> using namespace std;
const int maxn = 33333 + 5;
typedef long long LL;
int a[10]; int main(){
int n, x;
while(cin >> n){
memset(a, 0, sizeof(a));
for(int i = 0; i < n; ++i){
cin >> x;
++a[x];
}
int m = n / 3;
bool ok = true;
if(a[5] || a[7]) ok = false;
if(a[1] < a[3] || a[6] < a[3]) ok = false;
a[1] -= a[3], a[6] -= a[3];
int a1 = a[3];
if(a[1] != a[2] || a[6] + a[4] != a[2]) ok = false;
int a2 = a[6];
int a4 = a[4]; if(!ok) printf("-1\n");
else{
for(int i = 0; i < a1; ++i) printf("1 3 6\n");
for(int i = 0; i < a2; ++i) printf("1 2 6\n");
for(int i = 0; i < a4; ++i) printf("1 2 4\n");
} }
return 0;
}
CodeForces 342A Xenia and Divisors (水题)的更多相关文章
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- codeforces 696A Lorenzo Von Matterhorn 水题
这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽 ...
- CodeForces 589I Lottery (暴力,水题)
题意:给定 n 和 k,然后是 n 个数,表示1-k的一个值,问你修改最少的数,使得所有的1-k的数目都等于n/k. 析:水题,只要用每个数减去n/k,然后取模,加起来除以2,就ok了. 代码如下: ...
- Codeforces Gym 100286G Giant Screen 水题
Problem G.Giant ScreenTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/con ...
- codeforces 710A A. King Moves(水题)
题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include ...
- codeforces 659A A. Round House(水题)
题目链接: A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard ...
- CodeForces 489B BerSU Ball (水题 双指针)
B. BerSU Ball time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- codeforces 702A A. Maximum Increase(水题)
题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...
随机推荐
- c# 关键字学习
partial class Test { public string str; public void get() { } } partial class Test { public int i; p ...
- Lamp 安装教程
Ubuntu 14.04 麒麟版安装:Apache+php5+mysql+phpmyadmin. LAMP是Linux web服务器组合套装的缩写,分别是Linux+Apache+MySQL+PHP. ...
- mysql的配置(图解)
一.配置MySQL数据库 1.解压绿色版mysql,如下图 二.安装服务 1.运行cmd(管理员版本,否则没有权限),如下图 2.运行命令mysqld –install安装服务,如下图: 如果不需要m ...
- ASU一位图形学老师推荐的book list
http://peterwonka.net/Documentation/BooksToRead.htm 包括数学.图形学.OpenGL等资料
- python变量、引用、拷贝之间的关系
Python中一切皆为对象,不管是集合变量还是数值型or字符串型的变量都是一个引用,都指向对应内存空间中的对象. 简而言之: 变量直接赋值:新变量本身及其内部的元素都与原变量指向相同的内存空间,并且值 ...
- PHP,JAVA,NET 开发比较
装载出处:http://www.cnblogs.com/sinlang5778/archive/2011/08/10/2133190.html 一.语言: PHP:PHP产生与1994年,其语法混合了 ...
- 一分钟学会 ConstraintLayout 之从属性角度理解布局
ConstraintLayout 在 Android 开发中,我们通常是手写布局,很少会用拖动来写布局,虽然 ConstraintLayout 在 I/O 上以拖动来展现了各种功能,我估计在以后开发中 ...
- 浅谈AVL树,红黑树,B树,B+树原理及应用(转)
出自:https://blog.csdn.net/whoamiyang/article/details/51926985 背景:这几天在看<高性能Mysql>,在看到创建高性能的索引,书上 ...
- python算法之快速排序
快速排序 快速排序(英语:Quicksort),又称划分交换排序(partition-exchange sort),通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据都比另外一部分的所 ...
- hibernate相关方法
uniqueResult() 当确定返回的实例只有一个或者null时 用uniqueResult()方法 代码示例: Session session = factory.openSession(); ...