hdu-5718 Oracle(水题)
题目链接:
Oracle
Time Limit: 8000/4000 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
The youngest and most beautiful is Psyche, whose admirers, neglecting the proper worship of the love goddess Venus, instead pray and make offerings to her. Her father, the king, is desperate to know about her destiny, so he comes to the Delphi Temple to ask for an oracle.
The oracle is an integer n without leading zeroes.
To get the meaning, he needs to rearrange the digits and split the number into <b>two positive integers without leading zeroes</b>, and their sum should be as large as possible.
Help him to work out the maximum sum. It might be impossible to do that. If so, print `Uncertain`.
For each test case, the single line contains an integer n (1≤n<10^10000000).
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} const LL mod=1e9+7;
const double PI=acos(-1.0);
const int inf=1e9;
const int N=1e7+10;
const int maxn=1e3+10;
const double eps=1e-6; char s[N];
int flag[11],ans[N]; int main()
{ int t;
read(t);
while(t--)
{
mst(flag,0);
scanf("%s",s);
int len=strlen(s),num=0;
For(i,0,len-1)if(s[i]=='0')num++;
if(num==len-1)cout<<"Uncertain\n";
else
{
int mmin=9;
For(i,0,len-1)flag[s[i]-'0']++;
For(i,1,9)
{
if(flag[i]){flag[i]--,mmin=i;break;}
}
int cnt=0;
for(int i=0;i<=9;i++)
while(flag[i]--)ans[++cnt]=i;
ans[1]+=mmin;
ans[len]=0;
for(int i=1;i<=len-1;i++)
{
ans[i+1]+=ans[i]/10;
ans[i]=ans[i]%10;
}
if(ans[len])printf("%d",ans[len]);
for(int i=len-1;i>0;i--)printf("%d",ans[i]);
printf("\n");
}
}
return 0;
}
hdu-5718 Oracle(水题)的更多相关文章
- hdu 5210 delete 水题
Delete Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...
- hdu 1251 (Trie水题)
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submi ...
- HDU 5703 Desert 水题 找规律
已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...
- HDU 4493 Tutor 水题的收获。。
题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...
- hdu 4802 GPA 水题
GPA Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4802 Des ...
- hdu 5718 Oracle 高精度
Oracle Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Problem ...
- hdu 4493 Tutor 水题
Tutor Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...
- hdu 5495 LCS 水题
LCS Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5495 Descr ...
- HDU 5718 Oracle(高精度)
Time Limit:4000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description There ...
- hdu 4891 模拟水题
http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...
随机推荐
- Laravel 之Artisan
简介: Artisan是Laravel中自带的命令行工具的名称: 由强大的Symfony Console组件驱动的: 提供了一些对应用开发有帮助的命令: 查看所有可用的Artisan的命令 php a ...
- Lucene 6.5.0 入门Demo(2)
参考文档:http://lucene.apache.org/core/6_5_0/core/overview-summary.html#overview.description 对于path路径不是很 ...
- NSArray,NSMutableArray的一些常用方法
不可变数组 ——NSArray 常用的初始化一个数组: NSArray *array1 = [[NSArray alloc] init]; NSArray *array2 = ...
- HDU - 5974 A Simple Math Problem (数论 GCD)
题目描述: Given two positive integers a and b,find suitable X and Y to meet the conditions: X+Y=a Least ...
- DFS与BFS对比
前面已经说过了深搜和广搜了,是不是有点还不是很好的分清他们?(其实分不分的请都没大有关系) 下面我们来看一看广搜与深搜的区别吧. 算法步骤上的区别 深度优先遍历图算法步骤: 1.访问顶点v 2,.依次 ...
- 转:c++ 11 新特性
声 明:本文源自 Danny Kalev 在 2011 年 6 月 21 日发表的<The Biggest Changes in C++11(and Why You Should Care)&g ...
- Mybatis批量插入与批量删除
转自:http://www.cnblogs.com/liaojie970/p/5577018.html (一)批量插入 Mapper.xml: <?xml version="1.0&q ...
- 解决Linux系统没有/etc/sysconfig/iptables文件
Linux系统中,防火墙默认是不开启的,一般也没有配置过任何防火墙的策略,所以不存在/etc/sysconfig/iptables文件. 一.常规解决方法: 1.在控制台使用iptables命令随便写 ...
- Linux下多线程编程-信号量
今天来谈谈线程的同步--信号量. 首先来看看一些概念性的东西: 如进程.线程同步,可理解为进程或线程A和B一块配合,A执行到一定程度时要依靠B的某个结果,于是停下来,示意B运行:B依言执行,再将结果给 ...
- 辅助方法 @Html.Raw与 HtmlString区别
//Html.Raw其实是调用 new Microsoft.AspNetCore.Html.HtmlString(xxx) @{ ViewData["Title"] = " ...