Time Limit:4000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

There is once a king and queen, rulers of an unnamed city, who have three daughters of conspicuous beauty.

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

The first line of the input contains an integer $ T $ $ (1 \le T \le 10) $, which denotes the number of test cases.

For each test case, the single line contains an integer $ n $ $ (1 \le n < 10 ^ {10000000}) $.

Output

For each test case, print a positive integer or a string `Uncertain`.

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(高精度)的更多相关文章

  1. hdu 5718 Oracle 高精度

    Oracle Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem ...

  2. hdu 5718(Oracle)大数加法

    曾经有一位国王,统治着一片未名之地.他膝下有三个女儿. 三个女儿中最年轻漂亮的当属Psyche.她的父亲不确定她未来的命运,于是他来到Delphi神庙求神谕. 神谕可以看作一个不含前导零的正整数n n ...

  3. HDU 5718 Oracle

    如果非零的数小于等于1个,则无解.否则有解. 取出一个最小的非零的数作为一个数,剩下的作为一个数,相加即可. #include<cstdio> #include<cstring> ...

  4. BestCoder 2nd Anniversary/HDU 5718 高精度 模拟

    Oracle Accepts: 599 Submissions: 2576 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/26 ...

  5. Hdu 5568 sequence2 高精度 dp

    sequence2 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=556 ...

  6. hdu 1042 N!(高精度乘法 + 缩进)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目大意:求n!, n 的上限是10000. 解题思路:高精度乘法 , 因为数据量比较大, 所以 ...

  7. HDU 4704 Sum (高精度+快速幂+费马小定理+二项式定理)

    Sum Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status  ...

  8. hdu 1042 N!(高精度乘法)

    Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in ...

  9. HDU 5047 Sawtooth 高精度

    题意: 给出一个\(n(0 \leq n \leq 10^{12})\),问\(n\)个\(M\)形的折线最多可以把平面分成几部分. 分析: 很容易猜出来这种公式一定的关于\(n\)的一个二次多项式. ...

随机推荐

  1. java后台接受app上传的图片

    package com.sujinabo.file; import java.io.File; import java.io.FileOutputStream; import java.io.IOEx ...

  2. smbaclient

    在linux中通过smbaclient获取windows的共享文件 列出windows的共享目录 $ smbclient -L .xxx -U administrator%password 进入指定共 ...

  3. Nuget 学习三

    后期管理: 登录 nuget 官网 https://www.nuget.org/ 可以搜索到自己的包: 点击进入,可进一步操作 如果你需要给自己的类型新增其他功能,或者修改之前的bug(反正就是修改代 ...

  4. oracle建表的时候同时创建主键,外键,注释,约束,索引

    --主键create table emp (id number constraint id_pr primary key ,name1 varchar(8));create table emp9 (i ...

  5. ionic for mac 新建与调试

    ionic官网:http://ionicframework.com/ 首先需要下载node.js,建议node管理方式请先详细查看林一篇博客http://www.cnblogs.com/minyc/p ...

  6. css 开发心得

    1.一个 div内的行内 元素 如何水平对齐 将内部的元素设为 float  ,然后设置 margin-top 对齐,然后 用伪类清楚浮动的影响

  7. seajs +gruntjs 合作开发

    nodejs的出现 让服务器端能运行 js commonjs规范 规范服务器端开发按照什么写法去写 包括模块化开发 ( 不同点 请求在本地 js加载) AMD规范 浏览器端开发的规范 (不同点: 浏览 ...

  8. background-size (设置背景图片的大小)

    设置背景图片的大小,以长度值或百分比显示(数值包括 长度length和百分比percentage),还可以通过cover和contain来对图片进行伸缩. 语法:background-size: au ...

  9. Java的关键字和标识符

    1.关键字 Java中共有52个关键字,其中有两个保留字,虽然查到百度百科上说是50个,但是事实确实是有52个(47+3+2). 1.1保留字 Java语言的的保留字是指在Java中商务预留的关键字 ...

  10. 微信小程序文档解读(一)--api提供支持有哪些

    本文重点在于小程序API提供的微信功能支持及获取用户信息的解读,具体的用法和调用不在本文讨论范围之内,文章基于20161222版文档解读 API官方文档原文链接 小程序API官方定义: 框架提供丰富的 ...