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连试试水的深浅..... ...
随机推荐
- HDU2085JAVA
核反应堆 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- mac 神奇时光机
http://bbs.zol.com.cn/nbbbs/d544_8216.html
- 简洁JS 日历控件 支持日期和月份选择
原文出处 以下这个JS日历控件是我的闲暇之余自己编写的,所有的代码全部在IE7/IE8/Firefox下面测试通过, 而且可以解决被iframe层遮盖的问题.现在只提供两种风格(简洁版和古典版)和两种 ...
- PHP制作简单的日历
在这里分享一个PHP制作的日历 <?php //万年历if($_GET['year']){$year = $_GET['year'];}else{$year = date("Y&quo ...
- c语言学习之基础知识点介绍(二):格式化控制符和变量的补充
上节简单介绍了c语言中的一些基础知识点,本节将对之前介绍的不够详细的知识点进行补充. 格式化控制符的消息介绍: %d的其他控制符: 1.%md:m代表这个整数位占用多少位,m是一个整数.实际数字不足的 ...
- SQL SERVER 高级编程 - 自定义函数 拾忆
每个人都很忙,但是花10分钟复习下,总结下基础东西还是很有益处的. 背景: 总结一句,使用简便,还能递归,是的SQL更简洁,相对比一大堆的关联语句,而且关联一大堆还不一定实现特定功能.而且共用部分可以 ...
- javascript创建对象(二)
原型模式:每创建一个函数都有一个prototype属性,它是一个指针,指向一个对象: 原型模式创建函数的方式: function Movie(){ }; Movie.prototype.name=&q ...
- windows 远程连接linux服务器
百度搜索“SSH Secure Shell Client” 并下载 2 点击Profiles选择add profiles 并添加profils名称 3 点击Profiles 填写远程linux的ip ...
- jQuery无刷新上传学习心得
记得刚离开大学,进入目前这家公司不到一个月时,有一位前辈给我们当时的新人讲了下JS无刷新上传的相关知识. 在此之前,一直都是在使用C#提供的服务器上传控件FileUpload,但是每次使用时,都会刷新 ...
- JavaScript Invalid Date Verify
if ( Object.prototype.toString.call(d) === "[object Date]" ) { // it is a date if ( isNaN( ...