CF A. Xenia and Divisors
题目大意:
n(为三的倍数)个数的一个序列(每个数均不大于7),找出a,b,c
a能被b整除,b能被c整除,序列中的每个数都被用到。
1 2 3 4 5 6 7
只有 1 2 4
1 2 6
1 3 6
才能满足。
设他们分别有 x,y,z个
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
using namespace std;
int a[];
map<int ,int>m;
int main()
{
int i,n;
int flag=; while(scanf("%d",&n)!=EOF)
{
m.clear();
memset(a,,sizeof(a));
//for(i=0; i<n; i++)
//printf("%d\n",m[i]);
for(i=; i<n; i++)
{
scanf("%d",&a[i]);
if(!flag)
{
if(a[i]==||a[i]==)flag=;
else m[a[i]]++;
}
}
//printf("%d %d %d %d\n",flag,m[1],m[3],m[6]);
if(flag||m[]+m[]!=m[]||m[]+m[]!=m[]||m[]>m[]||m[]>m[])
{//m[4]>m[2]||m[3]>m[6]又写漏了判断条件,WA死的节奏
printf("-1\n");
}
else
{
for(i=; i<m[]; i++)
printf("1 2 4\n");
for(i=; i<m[]-m[]; i++)
printf("1 2 6\n");
for(i=; i<m[]; i++)
printf("1 3 6\n");
} }
//sort(a,a+n);
return ;
}
CF A. Xenia and Divisors的更多相关文章
- Xenia and Divisors
Xenia and Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- CF #635D Xenia and Colorful Gems 枚举+二分
Xenia and Colorful Gems 题意 给出三个数组,在每个数组中选择一个数字x,y,z,,使得\((x-y)^2+(y-z)^2+(x-z)^2\)最小. 思路 我们假设x<=y ...
- codeforces A. Xenia and Divisors 解题报告
题目链接:http://codeforces.com/problemset/problem/342/A 题目意思:给出n个数,找出n/3个组且每组有3个数,这三个数必须要符合两个条件:1.a < ...
- Codeforces Round #199 (Div. 2) A Xenia and Divisors
注意题目的数字最大是7 而能整除的只有 1,2,3,4,6,故构成的组合只能是1,2,4 或1,2,6或1,3,6,故分别统计1,2,3,4,6的个数,然后再分配 #include <iostr ...
- cf D. Xenia and Hamming
http://codeforces.com/contest/357/problem/D 题意:给你两个数n和m,表示两个字符串的循环次数,然后给出两个字符串,求出其相同位置字符不同的个数. 先求出两个 ...
- cf C. Xenia and Weights
http://codeforces.com/contest/339/problem/C #include <cstdio> #include <cstring> #includ ...
- CodeForces 342A Xenia and Divisors (水题)
题意:给定 n 个数(小于等于7),让你把它分成 m 组,每组有三个数,且满足,a < b < c,并且 a 能整除 b,b 能整除 c. 析:对于这个题,因为题目说了是不大于7的,那么一 ...
- 【Codeforces 342A】Xenia and Divisors
[链接] 我是链接,点我呀:) [题意] [题解] 最后a,b,c只有以下3种情况 1,2,4 1,2,6 1,3,6 那么用cnt[8]统计每个数字出现的次数. 输出cnt[4]次1,2,4 (如果 ...
- CodeForces Round 199 Div2
完了,这次做扯了,做的时候有点发烧,居然只做出来一道题,差点被绿. My submissions # When Who Problem Lang Verdict Time Memory 443 ...
随机推荐
- html a 链接
1.链接元素 文本.图像.热区 2.标记 描述性文字 target窗口形式 _self:在自身窗口打开(默认) _blank:在新窗口打开 _parent:在父窗口打开 _top:在顶窗口打开 框架或 ...
- 为SM30视图分配事务代码
Tcode:SE93
- P3380: [Usaco2004 Open]Cave Cows 1 洞穴里的牛之一
还是蛮简单的一道题,首先dfs一遍,在所有能到达放有干草的洞穴的所有路径中,找出路径上最小伐值的最大值,按这个值由小到大,再来一遍贪心就行了,能放就放,不能放拉倒(也可以理解为,不能放把最前一个删了) ...
- OC学习笔记之属性详解和易错点
属性的概念在OC1.0中就存在,格式是定义实例变量,然后定义setter和getter方法,用点操作符操作属性 举例,类的接口部分 @interface Father : NSObject { NSI ...
- LintCode-Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value. You ...
- Sprint计划会议1
会议时间:4.15.晚9点 会议地点:学一食堂2楼 会议进程 • 首先我们讨论了实验第一个Sprint1要实现的功能(用户登录及信息录入).• 之后对任务进行了认领.• 最后每个人对自己的任务进行 ...
- 课题练习——找从1到N出现的1的个数
#include<iostream.h>#include<conio.h>int Sum1(int n){ int count = 0; //记录1的个数 int factor ...
- PyDev for Eclipse 简介
PyDev 安装和配置 安装 PyDev 在安装 PyDev 之前,要保证您已经安装了 Java 1.4 或更高版本.Eclipse 以及 Python.接下来,开始安装 PyDev 插件. 启动 E ...
- Spring MVC mapping[From Spring MVC Beginner's Guide]
In a Spring MVC application, the URL can logically be divided into five parts (see the following fig ...
- 第七周技术博客发表 web网页开发
a<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org ...