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 ...
随机推荐
- java使用jxl,自动导出数据excle,quartz自动发送邮件
=============JAVA后台代码===================== package com.qgc.service.autoSendMsg.AutoSendMsg import ja ...
- 42.QT-QSqlQuery类操作SQLite数据库(创建、查询、删除、修改)详解
Qt 提供了 QtSql 模块来提供平台独立的基于 SQL 的数据库操作.这里我们所说的“平台 独立”,既包括操作系统平台,也包括各个数据库平台,Qt支持以下几种数据库: QT自带SQLITE数据库, ...
- HDU - 5572 An Easy Physics Problem (计算几何模板)
[题目概述] On an infinite smooth table, there's a big round fixed cylinder and a little ball whose volum ...
- T3139 栈练习3 codevs
http://codevs.cn/problem/3139/ 题目描述 Description 比起第一题,本题加了另外一个操作,访问栈顶元素(编号3,保证访问栈顶元素时或出栈时栈不为空),现在给出这 ...
- MongoDB学习day10--Mongoose的populate实现关联查询
一.Mongoose populate官方文档 https://mongoosejs.com/docs/populate.html 二.Mongoose populate关联查询 1.定义ref va ...
- linxu下的shell脚本加密,shell生成二机制可执行文件
再安全的加密也抵不过逆向,斗智斗勇吧,持续加密持续破解 1.简单的加密:gzexe file.sh 2.使用shc加密:下载地址:http://www.datsi.fi.upm.es/~frosal/ ...
- QML 开发神奇加成之为网络资源设置本地缓存
QML 开发神奇加成之为网络资源设置本地缓存 直接上码: #include <QNetworkAccessManager> #include <QNetworkDiskCache&g ...
- 【转】Code Your Own PHP MVC Framework in 1 Hour
原文: https://www.codeproject.com/Articles/1080626/Code-Your-Own-PHP-MVC-Framework-in-Hour --------- ...
- 上传jar包至maven私服
1.maven环境变量配置(新建系统变量,编辑Path) 2.修改maven的setting文件 2.1 私服的用户配置 2.2 私服镜像配置 2.3 (我也不知道是啥) <profile> ...
- ActiveMQ(六) 转
package pfs.y2017.m11.mq.activemq.demo07; import org.apache.activemq.ActiveMQConnectionFactory; impo ...