Codeforces Round #131 (Div. 2) : B
首先能被2,5整除的数结尾必须是0;
如果没有0肯定不行;
然后判断他们的和ans%3:
如果==0,直接从大到小输出就行;
如果==1,要么删除它们之间最小的那个%3==1的,要么删除两个小的并且%3==2的;
如果==2,要么删除它们之中最小的那个%2==2的,要么删除两个小的并且%3==1的;
代码:
#include<iostream>
using namespace std;
int n,d[],a,u;
main()
{
cin>>n;
while(n--)cin>>a,++d[a],u+=a;
if(u%)
{
for(int i=; i<; ++i)
if(i%==u% && d[i])
--d[i],u-=i,i=;
for(n=; n<; ++n)
for(int i=; i<; ++i)
if(u%&&i%&&d[i])
--d[i],u-=i,i=;
}
if(!u)d[]=;
if(!d[]||u%)cout<<-;
else
for(int i=; i>=; --i)
while(d[i]--)
cout<<i;
return ;
}
Codeforces Round #131 (Div. 2) : B的更多相关文章
- Codeforces Round #131 (Div. 1) B. Numbers dp
题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...
- Codeforces Round #131 (Div. 2) B. Hometask dp
题目链接: http://codeforces.com/problemset/problem/214/B Hometask time limit per test:2 secondsmemory li ...
- Codeforces Round #131 (Div. 2) E. Relay Race dp
题目链接: http://codeforces.com/problemset/problem/214/E Relay Race time limit per test4 secondsmemory l ...
- Codeforces Round #131 (Div. 2)
A. System of Equations \(a\)的范围在\(\sqrt n\)内,所以暴力枚举即可. B. Hometask 需要被2.5整除,所以末位必然为0,如果0没有出现,则直接返回-1 ...
- Codeforces Round #131 (Div. 1) A - Game
A. Game time limit per test 1 second memory limit per test 256 megabytes input standard input output ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
随机推荐
- 项目中发现的一些关于JavaScript中JSON的注意点
一个是怎样创建JSON: var obj = {}; obj['name'] = value; obj['anotherName'] = anotherValue; 假设要创建多级的JSON,则: i ...
- 【转】学习Flex ActionScript 3.0 强烈推荐电子书
学习Flex ActionScript 3.0 强烈推荐电子书 AdvancED ActionScript 3.0 Animation(<Make things move>姐妹篇,强烈推 ...
- QT开发pjsip的VOIP,A8平台运行
QT开发pjsip的VOIP 开发环境 平台:A8 环境:Linux-3.0.8 实现功能:使用QT开发VOIP进行初始化.拨号.挂起 测试工具:minisipserver服务器 效果 界面: min ...
- python学习笔记--Django入门三 Django 与数据库的交互:数据建模
把数据存取逻辑.业务逻辑和表现逻辑组合在一起的概念有时被称为软件架构的 Model-View-Controller (MVC)模式.在这个模式中, Model 代表数据存取层,View 代表的是系统中 ...
- ubuntu中安装eclipse 分类: android ubuntu linux 学习笔记 2015-07-07 10:19 75人阅读 评论(0) 收藏
上一篇说了安装jdk的事,于是趁热打铁,决定把eclipse也安装了. 下载这一系列就不用说了. 下载完成之后: 然后解压,解压之后文件剪切到/usr/software文件夹中,同时重命名为eclip ...
- Linux删除文件Argument list too long问题的解决方案
方法一:使用find find . -name 文件 | xargs rm -f 但文件数量过多,find命令也会出现问题: -bash: /bin/find: Argument list too l ...
- HTML+CSS基础学习笔记(8)
一.水平居中设置--行内元素 如果设置元素为文本.图片等行内元素时,水平居中是通过给父元素设置text-align:center来实现的 二.水平居中设置 --定宽块状元素 #当被设置元素为块状元素时 ...
- (转)Apache2 httpd.conf 配置详解 (二)
转之--http://jafy00.blog.51cto.com/2594646/508205 DocumentRoot "/usr/local/apache-2.2.6/htdocs&qu ...
- cas系列(三)--HTTP和HTTPS、SSL
(这段时间打算做单点登录,因此研究了一些cas资料并作为一个系列记录下来,一来可能会帮助一些人,二来对我自己所学知识也是一个巩固.) 本文转自異次元藍客点击打开链接 1. HTTPS HTTPS(全 ...
- JAVA zip解压 MALFORMED 错误
最近在在使用zip 解压时,使用JDK1.7及以上版本在解压时,某些文件会报异常 Exception in thread "main" java.lang.IllegalArgum ...