小K手中有n张牌,每张牌上有一个一位数的数,这个字数不是0就是5。小K从这些牌在抽出任意张(不能抽0张),排成一行这样就组成了一个数。使得这个数尽可能大,而且可以被90整除。

注意:

1.这个数没有前导0,

2.小K不需要使用所有的牌。

Input
每个测试数据输入共2行。
第一行给出一个n,表示n张牌。(1<=n<=1000)
第二行给出n个整数a[0],a[1],a[2],…,a[n-1] (a[i]是0或5 ) 表示牌上的数字。
Output
共一行,表示由所给牌组成的可以被90整除的最大的数,如果没有答案则输出”-1”(没有引号)
Input示例
4
5 0 5 0
Output示例
0
各位之和为9的倍数可以整除9
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 0x3f3f3f3f
#define mem(a) ((a,0,sizeof(a)))
typedef long long ll;
int a[],n,x;
int main()
{
scanf("%d",&n);
a[]=a[]=;
for(int i=;i<n;i++)
{
scanf("%d",&x);
a[x/]++;
}
a[]/=;
if(!a[]) return printf("-1\n"),;
if(!a[]) return printf("0\n"),;
while(a[]--) printf("");
while(a[]--) printf("");
printf("\n");
return ;
}

最新文章

  1. 多线程并发同一个表问题(li)
  2. java问卷
  3. Guava - EventBus(事件总线)
  4. JAVA - IDEA快捷键(精简版)
  5. 数据结构杂谈(二)简单有趣的地精排序Gnome sort
  6. css学习(1)-- 层叠样式表CSS的基础
  7. android 数据文件存取至储存卡
  8. 解决:错误 14274: 无法添加、更新或删除 SQL 服务器上的作业的问题一例
  9. weiapi2.2 HelpPage自动生成接口说明文档和接口测试功能
  10. 502 Bad Gateway nginx 解决
  11. 【MongoDB】MongoDB服务器搭建(Unix/Linux)
  12. 浏览器兼容CSS代码:按钮文字垂直居中(input button text vertical align)
  13. HDU 1226 BFS
  14. 使用PyInstaller打包Python程序
  15. C#学习笔记(3)
  16. 03_JqueryAjax_异步请求Servlet
  17. python json string和dict的转化
  18. Python 3语法小记(四)字典 dictionary
  19. php管理关系工具Composer 之安装与下载
  20. svn部署项目

热门文章

  1. 子文件夹的遍历(python、matlab)
  2. BZOJ 2096 单调队列
  3. P2742 [USACO5.1]圈奶牛Fencing the Cows
  4. 14:Challenge 7(map大法好)
  5. 51nod 1448 二染色问题 (逆向考虑)
  6. 【原创】JAVA word转html
  7. [国家集训队]最长双回文串 (PAM)回文自动机
  8. oracle查询之null值转化
  9. 关于wdsl
  10. NodeJS学习笔记 (5)网络服务-http-req(ok)