HDU 5718 Oracle(高精度)
Time Limit:4000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
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`.
Input
For each test case, the single line contains an integer $ n $ $ (1 \le n < 10 ^ {10000000}) $.
Output
Sample Input
3
112
233
1
Sample Output
22
35
Uncertain
Hint
In the first example, it is optimal to split $ 112 $ into $ 21 $ and $ 1 $, and their sum is $ 21 + 1 = 22 $. In the second example, it is optimal to split $ 233 $ into $ 2 $ and $ 33 $, and their sum is $ 2 + 33 = 35 $. In the third example, it is impossible to split single digit $ 1 $ into two parts.
#include<cstdio>
#include<iostream>
#include<cstring>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define N 10000005
char s[N];
int main()
{
int T,len,minn,mi,i;
scanf("%d",&T);
while(T--)
{
scanf("%s",&s);
len=strlen(s);
sort(s,s+len);
if(len==||s[len-]=='')
printf("Uncertain\n");
else
{
for( i=;i<len;i++)
if(s[i]!='')
{
minn=i;
mi=s[i]-'';
break;
}
for(i=minn;i>;i--)
s[i]=s[i-];//接下来都是从1开始
s[]+=mi;
for(i=;i<len-;i++)
{
if(s[i]>'')
{
s[i+]++;
s[i]-=;
}
else
break;
}
printf("%d",s[len-]-'');
for(i=len-;i>=;i--)
printf("%c",s[i]);
printf("\n");
}
}
return ;
}
HDU 5718 Oracle(高精度)的更多相关文章
- hdu 5718 Oracle 高精度
Oracle Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Problem ...
- hdu 5718(Oracle)大数加法
曾经有一位国王,统治着一片未名之地.他膝下有三个女儿. 三个女儿中最年轻漂亮的当属Psyche.她的父亲不确定她未来的命运,于是他来到Delphi神庙求神谕. 神谕可以看作一个不含前导零的正整数n n ...
- HDU 5718 Oracle
如果非零的数小于等于1个,则无解.否则有解. 取出一个最小的非零的数作为一个数,剩下的作为一个数,相加即可. #include<cstdio> #include<cstring> ...
- BestCoder 2nd Anniversary/HDU 5718 高精度 模拟
Oracle Accepts: 599 Submissions: 2576 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/26 ...
- Hdu 5568 sequence2 高精度 dp
sequence2 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=556 ...
- hdu 1042 N!(高精度乘法 + 缩进)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目大意:求n!, n 的上限是10000. 解题思路:高精度乘法 , 因为数据量比较大, 所以 ...
- HDU 4704 Sum (高精度+快速幂+费马小定理+二项式定理)
Sum Time Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64u Submit Status ...
- hdu 1042 N!(高精度乘法)
Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in ...
- HDU 5047 Sawtooth 高精度
题意: 给出一个\(n(0 \leq n \leq 10^{12})\),问\(n\)个\(M\)形的折线最多可以把平面分成几部分. 分析: 很容易猜出来这种公式一定的关于\(n\)的一个二次多项式. ...
随机推荐
- 【repost】js字符串函数
JS自带函数concat将两个或多个字符的文本组合起来,返回一个新的字符串.var a = "hello";var b = ",world";var c = a ...
- IIS配置 Web部署 svg/woff/woff2字体 404错误
一,woff/woff2字体 404错误,这个可以在浏览器按F12的Console页面可以发现问题,如下图: 解决方法: 一,打开服务器IIS管理器,找到MIME类型 二,添加MIME类型 添加三条: ...
- Linux 分区挂载方案
/boot 1G swap 2G(看内存决定) / 10-15G /home 5G
- mybatis学习笔记四(动态sql)
直接贴图,注解在代码上,其他的配置文件在学习一中就不贴了 1 数据库 2 实体类 package com.home.entity; /** * 此类是: 用户实体类 * @author hpc * @ ...
- Openjudge-NOI题库-和为给定数
题目描述 Description 给出若干个整数,询问其中是否有一对数的和等于给定的数. 输入输出格式 Input/output 输入格式: 共三行: 第一行是整数n(0 < n <= ...
- java操作mongodb——连接数据库
import com.mongodb.MongoClient; MongoClient mongoClient = new MongoClient(); 连接MongoDB实例,默认为localhos ...
- Java NIO Channel和Buffer
Java NIO Channel和Buffer @author ixenos Channel和Buffer的关系 1.NIO速度的提高来自于所使用的结构更接近于OS执行I/O的方式:通道和缓冲器: 2 ...
- Zeppelin0.5.6使用hive解释器
此zeppelin为官方0.5.6版,可能还在孵化阶段,可能出现一些bug吧. 配置 cp zeppelin-env.sh.template zeppelin-env.sh vi zeppelin-e ...
- iosAPP打包上架xcode中Archive提交成功以后,不提示构建版本问题
最近在项目更新时遇到Archive提交到开发者中心成功后,一直不提示构建版本信息,可能导致的原因是由于ios10以后对于APP中调用手机相册或摄像头麦克风时需要配置plist文件,配置如下内容或许会解 ...
- PEiD 0.95 全插件中文绿色版
软件名称: PEiD 0.95 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win8 / Win7 / Vista / WinXP 软件大小: 4.4MB 图片预览: 软件简介: PEiD ...