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 ...
随机推荐
- idea 破解代码
下面是idea的破解方法,手动执行对应的main方法即可.亲测Idea 14 完美破解~~废话少说,上代码... package com.jd.serializable; import java.ma ...
- JAVA构造函数在超类与子类定义鲁波总结
1.子类无构造函数,超类无构造函数,创建的无参数的对象: 编译通过. class A { } class B extends A { } public class Testeeer { public ...
- 转-----FPGA工程师:持守梦想or屈于现实
昨晚无意间看到一段新闻频道对最近炒得火热的“史上最年轻教授”的专访,倒是他的一位同学对于梦想的“现实版”解说颇有些耐人寻味.大体意思是说“拼了老命考上一所梦寐以求的大学,父母辛辛苦苦交了学费,我们却 ...
- PHP处理session跨域
同一根域名下子域名之间的跨域 ini_set('session.name', 'sid'); //设置session_id的键名 ini_set('session.use_trans_sid', 0) ...
- 仅用CSS3创建h5预加载交错圈
<head> <meta charset="UTF-8"> <title></title> <style type=" ...
- Julia - 字符串
字符 字符使用单引号括起来,字符是 32 位整数 julia> 'a' 'a': ASCII/Unicode U+0061 (category Ll: Letter, lowercase) ju ...
- Halcon学习(三)赋值与数组操作
assign : 对数据赋值,对数组的初始化.但不能对数组中的某一个值进行赋值. 举例:Tuple1 := [1,0,3,4,5,6,7,8,9] // 对数组进行初始化 Val := sin( ...
- interrupt 1 using 1
释疑:void Timer0() interrupt 1 using 1 Timer0 是函数名,随便取的 interrupt xx using y 跟在interrupt 后面的 ...
- 汉字转拼音开源工具包Jpinyin介绍
最近要实现一个根据词语得到词语对应拼音的功能,找到了Jpinyin这个开源工具包,使用下来发现它非常强大,完全满足我的需求,下面对它做一个简单的介绍,希望能够帮助到有需要的朋友. https://gi ...
- docker学习记录1
起因 现在自己学习微服务,服务器越来越多,虽然自己写了一些shell脚本来安装需要的软件,比如mysql,redis,jdk等等,但是还是好麻烦.希望学习docker能够快速安装部署这些东西. 记录一 ...