首先能被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的更多相关文章

  1. Codeforces Round #131 (Div. 1) B. Numbers dp

    题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...

  2. Codeforces Round #131 (Div. 2) B. Hometask dp

    题目链接: http://codeforces.com/problemset/problem/214/B Hometask time limit per test:2 secondsmemory li ...

  3. Codeforces Round #131 (Div. 2) E. Relay Race dp

    题目链接: http://codeforces.com/problemset/problem/214/E Relay Race time limit per test4 secondsmemory l ...

  4. Codeforces Round #131 (Div. 2)

    A. System of Equations \(a\)的范围在\(\sqrt n\)内,所以暴力枚举即可. B. Hometask 需要被2.5整除,所以末位必然为0,如果0没有出现,则直接返回-1 ...

  5. 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 ...

  6. 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 ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. 偷偷mark下一个

    java书单 thinking in java java战 Effective Java 深入了解JVM虚拟机 java性能优化权威指南 JSR133 Google Guava官方教程 版权声明:本文 ...

  2. 【转】copy 和 mutablecopy (深拷贝和浅拷贝)

    阅读本文之前首先了解copy与retain的区别,如果有不正确的地方望大家多多指教: copy与retain的区别: copy是创建一个新对象,retain是创建一个指针,引用对象计数加1.Copy属 ...

  3. mysql 导入excel 或 .csv

    第一步 导出excel 去掉列头,设置文本里面格式

  4. iOS 关于开发者证书:此证书的签发者无效的解决方案

    备注:第二个步骤一定要进行,否则弄到吐血,还是现实签发者无效 ---------------------- 1,按照你那个链接下载,https://developer.apple.com/certif ...

  5. enable cors in spring mvc with swagger

    a. In controller add @CrossOrigin(origins = "http://localhost:8080") b. In mvc-servlet.xml ...

  6. easyui-treegrid移除树节点出错

    easyui-treegrid移除树节点出错 >>>>>>>>>>>>>>>>>>>& ...

  7. ASP.NET MVC 第七回 UrlHelper

    这节讲 一下ASP.NET MVC中的Helper. 何谓Helper,其实就是在View中为了实现一些灵活功能而写的方法组. 其实ASP.NET MVC的View是Aspx的页面,本身可以声明定义方 ...

  8. 《你不常用的c#之一》:略谈unsafe

    转自csdn:http://blog.csdn.net/robingaoxb/article/details/6199508 msdn里讲到: “在 C# 中很少需要使用指针,但仍有一些需要使用的情况 ...

  9. 写一个最简单的 Server

    import java.net.*;import java.io.*;public class Server{ public static void main(String[] args) throw ...

  10. Asp.Net Mvc4 Ajax提交数据成功弹框后跳转页面

    1.cshtml页面代码 @model Model.UserInfo @{     ViewBag.Title = "Edit"; var options = new AjaxOp ...