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\)的一个二次多项式. ... 
随机推荐
- java基础练习 6
			public class Sixth { /*一个数如果恰好等于它的因子之和,这个数就称为"完数".例如6=1+2+3.编程 找出1000以内的所有完数.*/ public sta ... 
- java基础练习 3
			import java.util.Scanner; public class Third { /*计算字符串中子串出现的次数 (5 分数)*/ public static void main(Stri ... 
- 字典(Tire树)
			4189 字典 时间限制: 1 s 空间限制: 256000 KB 题目等级 : 大师 Master 题目描述 Description 最经,skyzhong得到了一本好厉害的字典,这个 ... 
- C++ unordered_map 在key为string类型和char*类型时测试时间性能差异
			测试系统liunx centos6.5 代码如下 #include <string.h> #include <sstream> #include <list> #i ... 
- C++ 处理 utf-8
			类似"abc汉字"这样的字符串是以utf-8编码; C++ 的 cout执行的操作是把参数发送给stdout,因此如果终端支持utf-8, 汉字可以使用cout打印: 比较好的办法 ... 
- yarn计算一个节点容量及其配置项
			mapred-site.xml mapreduce.map.memory.mb 1536 每个Map Container的大小 mapreduce.reduce.memory.mb 2560 每个Re ... 
- Logstash利用GeoIP库显示地图以及通过useragent显示浏览器(四)
			我们通过Logstash收集的Nginx Access log中已经包含了客户端IP的数据(remote_addr),但是只有这个IP还不够,要在Kibana的显示请求来源的地理位置还需要借助GeoI ... 
- python3 获取阿里云ECS 实例及监控的方法
			#!/usr/bin/env python3.5 # -*- coding:utf8 -*- try: import httplib except ImportError: import http.c ... 
- 进度管理工具 planner
			ganttproject 太简单,连个子项目都做不了.(也可能是我不会用,后来发现用缩进就可以了.呵呵).又重新有网上搜了一下,发现PLANNER符合我的想法... *进官网,下载. #tar xvJ ... 
- MQTT协议之 Apache Apollo服务
			一.说明 MQTT是IBM开发的一个即时通讯协议,有可能成为物联网的重要组成部分.该协议支持所有平台,几乎可以把所有联网物品和外部连接起来,被用来当做传感器和致动器(比如通过Twitter让房屋联网) ... 
