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 ...
随机推荐
- 打开图片并显示在面板上demo
import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ...
- RefWorks
RefWorks公司简介/RefWorks 编辑 RefWorks是美国剑桥信息集团的子公司,是ProQuest 的姊妹公司.该公司于2001年由参考文献管理领域的一些专家组建而成,并致力于为学术机构 ...
- IO模型之阻塞IO
1. IO模型的介绍 首先我们先来熟悉下什么是 同步,异步.阻塞.非阻塞 的知识: 同步(synchronous) IO和异步(asynchronous) IO,阻塞(blocking) IO和非阻塞 ...
- linux-强制断开远程tcp连接
最近在做日常维护,搭建了socks代理,但是socks代理服务已经关闭了,由于其他机器还在和我的服务器保持tcp长连接 e.g. tcp ESTAB Google了一下,没找到特别好的办法,例如ipt ...
- BFC以及margin的深入探究
BFC(Block Formatting Context) 块级格式化上下文,它是指一个独立的块级渲染区域,只有block-level Box参与,该区域拥有一套渲染规则来约束块级盒子的布局,且与区域 ...
- 在ubuntu中添加新硬盘
在ubuntu中添加新硬盘 转载于 http://www.cnblogs.com/unipower/archive/2009/03/08/1406230.html 前言 安装新硬盘这种事情并不会经常 ...
- 第四章:重构代码[学习Android Studio汉化教程]
第四章 Refactoring Code The solutions you develop in Android Studio will not always follow a straight p ...
- App压力测试背景
开展压力测试 原因: 提高产品的稳定性 提高产品的留存率 时间: 首轮功能测试通过 夜间进行(将工具设置后进行,节约资源) 如何开展: 确定事件流 模拟事件流
- 一个不明觉厉的貌似包含很多linux资料索引的网页
http://man.lupaworld.com/content/other/Linux/linuxmanage/node108.html 貌似是个官方的doc之类的...
- LNK2026: 模块对于 SAFESEH 映像是不安全的<转>
转自VC错误:http://www.vcerror.com/?p=162 错误描述: 在使用VS2012编译工程时,提示错误:" error LNK2026: 模块对于 SAFESEH 映像 ...