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 ...
随机推荐
- 使用mysql-connector-java出现的错误
如果你使用的是mysql-connector-java6.*版本,并使用c3p0连接池的话,就可能出错.因为最近在使用Maven构建项目,想着换成最新的版本试试,就是用了个mysql-connecto ...
- TypeError: 'ExcelData' object is not iterable
今天写了个测试的代码,结果在执行test_register.py文件在调用readexcle.py的时候一直报错TypeError: 'ExcelData' object is not iterabl ...
- win iso download
http://rufus.akeo.ie/ window iso download http://win.86tyu.cn/ylmf32win7.html
- svn代码回滚和合并的利器svn merge
1.svn merge可以将两个对象的diff体现到本地工作目录上. (1)两个对象 这个两个对象可以是同一个svn url的两个revison,也可以是不用的url,比如分支和主干. (2)diff ...
- 巧用setTimeout函数设置程序后门
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Excel中通过向导方式插入chart
1.插入图表则主要是操作ChartObject对象和Chart对象. Workbook wb = xla.Workbooks.Add(XlSheetType.xlWorksheet); Workshe ...
- 什么是事件代理?DOM2.0标准事件模型的三个阶段
体验更优排版请移步原文:http://blog.kwin.wang/programming/js-event-delegation.html 事件代理,又称事件委托(Delegation),就是将处理 ...
- Redis实战——安装问题汇总
借鉴:https://www.cnblogs.com/liu2-/p/6914159.html 通用方法:迅速查看缺少的包的路径,并安装 yum provides *** 如 yum provides ...
- 拼接两个yuv合帧
http://blog.csdn.net/huahuahailang/article/details/9040847 /**************************************** ...
- python:数组/列表(remove()函数、append()函数、sort()函数、reverse()函数)
排序: 1:整理顺序 #冒泡 lista = [5,7,11,19,99,63,3,9,1] list = [] while lista != []: number = 0 for i in list ...