BestCoder 2nd Anniversary 1001 Oracle
找到最小的非零数字拆开来相加。
高精度。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
#define LL long long
char s[];
int a[],b[];
int t,p;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%s",s);
int len=strlen(s);
p=;
if(len==)//只有一个数字,不符合
{
puts("Uncertain"); continue;
}
for(int i=;i<len;i++)
{
a[i]=s[i]-'';
if(a[i]!=) p++;
}
if(p<=)//非零数字不足两个,不符合
{
puts("Uncertain"); continue;
}
sort(a,a+len);
for(int i=;i<len;i++)//找到最小的非零数字
{
if(a[i]!=)
{
p=i; break;
}
}
int j=;
for(int i=;i<len;i++)
{
if(i==p) continue;
b[j++]=a[i];
}
b[]+=a[p];//相加
b[j]=;
for(int i=;i<j;i++)//高精度进位
{
if(b[i]<) break;
b[i+]+=b[i]/;
b[i]%=;
}
if(b[j]>) j++;
for(int i=j-;i>=;i--)
printf("%d",b[i]);
puts("");
}
}
BestCoder 2nd Anniversary 1001 Oracle的更多相关文章
- BestCoder 2nd Anniversary的前两题
Oracle Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Su ...
- BestCoder 2nd Anniversary
A题 Oracle http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=703&pid=1001 大数相加: ...
- BestCoder 2nd Anniversary/HDU 5718 高精度 模拟
Oracle Accepts: 599 Submissions: 2576 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/26 ...
- hdu 5719 BestCoder 2nd Anniversary B Arrange 简单计数问题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5719 题意:一个数列为1~N的排列,给定mn[1...n]和mx[1...n],问有符合的排列数为多少 ...
- hdu 5720 BestCoder 2nd Anniversary Wool 推理+一维区间的并
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5720 题意:有n(n <= 105)个数 ,每个数小于等于 1018:问在给定的[L,R]区间中 ...
- BestCoder 2nd Anniversary 1002 Arrange
排除所有不符合条件后根据当前位置上下界计算, 由于前面取的数肯定在之后的区间内,所以去掉已取的个数即可. #include <iostream> #include <cstdio&g ...
- BestCoder 2nd Anniversary/HDU 5719 姿势
Arrange Accepts: 221 Submissions: 1401 Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/2 ...
- 贪心 BestCoder Round #39 1001 Delete
题目传送门 /* 贪心水题:找出出现次数>1的次数和res,如果要减去的比res小,那么总的不同的数字tot不会少: 否则再在tot里减去多余的即为答案 用set容器也可以做,思路一样 */ # ...
- 二分图点染色 BestCoder 1st Anniversary($) 1004 Bipartite Graph
题目传送门 /* 二分图点染色:这题就是将点分成两个集合就可以了,点染色用dfs做, 剩下的点放到点少的集合里去 官方解答:首先二分图可以分成两类点X和Y, 完全二分图的边数就是|X|*|Y|.我们的 ...
随机推荐
- TCP/IP 3次握手
参看下面链接:http://blog.chinaunix.net/uid-20665047-id-3137792.html
- mybatis_Generator配置
mybatis-generator-core-1.3.2 <?xml version="1.0" encoding="UTF-8"?> <!D ...
- Js中单引号和双引号的区别
<html> <body> <input value="外双引号内双引号-错误" type="button" onclick=&q ...
- [ofbiz]service中OUT的定义
在service中返回的任何一个结果,比如map1,map2,然后这两个map又封装在另一个map中,则service的定义中,要将map1和map2定义为OUT类型 LOFTER:我们的故事 h ...
- nginx+keepalived+tomcat之具体配置档
前沿知识点: nginx负责负载均衡(反向代理) msm(memcached session manager)负责缓存会话信息,从而实现会话保持 所需包: nginx和memcached采用最新稳定版 ...
- Excel导出cs文件
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI ...
- wget 测试cdn
可以通过wget 或curl 指定代理ip来访问同一个链接的不同cdn响应页面.来测试不同cdn间的数据同步问题.
- hdu 1355 The Peanuts
http://acm.hdu.edu.cn/showproblem.php?pid=1355 #include <cstdio> #include <iostream> #in ...
- 压缩、解压缩流GZipStream
如果要在压缩过程中检查错误或要与其他操作系统所用程序共享压缩数据,则要是用GZipStream类.GZipStream类包含是用GZip数据格式进行压缩和解压缩文件的方法,该类不能用于解压缩大于4GB ...
- Silverlight 结合ArcGis 使用inforwindow
原文 http://www.dotblogs.com.tw/justforgood/archive/2012/05/10/72089.aspx 也许有些人不知道什么事inforwindow,简单来说就 ...