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