7-16 Bestcoder a Oracle
Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 325 Accepted Submission(s): 139
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<1010000000).
112
233
1
35
Uncertain
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<iostream>
#include<stdio.h>
#include<string>
#include<string.h>
using namespace std;
char num[];
int ans[];
int main()
{ int t;
scanf("%d",&t);
getchar();
while(t--)
{
int i=;
int ge[];
for(int j=; j<; j++) ge[j]=;
scanf("%s",num);
int len=strlen(num);
if(len<=)
{
printf("Uncertain\n");
}
else
{
for(int i=;i<len;i++){
ge[num[i]-'']++;
}
int cnt=;
for(int i=;i>=;i--){
for(int j=;j<ge[i];j++){
ans[cnt++]=i;
}
}
// for(int i=0;i<cnt;i++) cout<<ans[i]<<" ";
int flag=;
if(ans[cnt-]==){
flag=;
for(int i=cnt-;i>;i--){
if(ans[i]!=){
flag=;
ans[cnt-]=ans[i];
ans[i]=;
break;
}
}
}
if(!flag){
printf("Uncertain\n");
continue;
}
int tmp=;
// for(int j=0; j<len; j++) cout<<ans[j]<<endl;
//cout<<len;
for(int j=len-; j>=; j--)
{
ans[j]=ans[j]+tmp;
if(j==len-) ans[j]=ans[j]+ans[len-];
if(ans[j]>=)
{
ans[j]-=;
tmp=;
}
else
{
tmp=;
}
}
if(tmp)
{
printf("");
}
for(int i=; i<=len-; i++)
printf("%d",ans[i]);
printf("\n");
} }
return ;
}
7-16 Bestcoder a Oracle的更多相关文章
- Ubuntu 16.04安装Oracle 11gR2入门教程图文详解
概述 Ubuntu版本:ubuntu-16.04.3-desktop-amd64 Oracle版本:linux.x64_11gR2_database ------------------------- ...
- 巡检脚本OS+Oracle
巡检脚本 主机巡检脚本:OSWatcher.sh Oracle巡检脚本:ORAWatcher.sh 脚本使用方法 1.建立脚本放置目录 # mkdir /var/collect 2.把脚本ORAWat ...
- C#连接Oracle数据库(直接引用dll使用)
转载至:http://www.cnblogs.com/gguozhenqian/p/4262813.html 项目中有个功能需要从一台Oracle数据库获取数据,本以为是很简单的事情,直接将原来的Sq ...
- linux环境下安装oracle数据库 原文在卡卡100http://www.cnblogs.com/kaka100
centos55_oracle11gr2_install 第一个阶段:安装centos55 a:安装centos5.5 用图形界面安装 硬盘 16G 注意:用图形界面安装.. 第二个阶段:配 ...
- RHEL每天定时备份Oracle
步骤: (1)创建脚本文件bak_112.sh,内容如下(自动按当前日期备份数据库): #!/bin/sh export ORACLE_BASE=/u01/app/oracle; ORACLE_HOM ...
- oracle进程
http://blog.csdn.net/leshami/article/details/5529239 Oracle实例和Oracle数据库(Oracle体系结构) 几类进程:用户进程,服务进程,后 ...
- Oracle迁移MySQL笔记
1,--在oracle代表注释 ,mysql/* */,# 2,|| oracle里面是表示连接符号,比如 A||B 那么就是AB 3,databaseLink创建好之后,比如名字为db_link_b ...
- Oracle bbed 实用示例-----File Header Reset
一.查看当前环境 1.1 当前控制文件中的SCN号 [oracle@ora10 ~]$ sqlplus /nolog SQL :: Copyright (c) , , Oracle. All righ ...
- Oracle DBA 的常用Unix参考手册(一)
作为一名Oracle DBA,在所难免要接触Unix,但是Unix本身又是极其复杂的,想要深刻掌握同样很不容易.那么到底我们该怎么入手呢?Donald K Burleson 的<Unix for ...
随机推荐
- Android之通知使用权
通知使用权打开方式 设置--提示音和通知--通知使用权. 具体界面如图: 存在须要拥有通知使用权应用时: 不存在须要拥有通知使用权应用时: 用户为应用勾选复选框后系统弹dialog须要用户进一步确认时 ...
- mysql 5.7之后版本datatime 不允许设置 0000-00-00 00:00:00 的问题
打开mysql.ini配置文件 在mysqld下 加入sql-model验证规则即可 sql-mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FO ...
- 【ACM】找新朋友
//make up a table of prime factors #include <stdio.h> #include <stdlib.h> #define MAX 32 ...
- block的知识点
// // main.m // 1211块练习 // // Created by jerehedu on 14/12/11. // Copyright (c) 2014年 jereh. All ...
- c语言指针详解 经典
指针是C语言中广泛使用的一种数据类型. 运用指针编程是C语言最主要的风格之一.利用指针变量可以表示各种数据结构: 能很方便地使用数组和字符串: 并能象汇编语言一样处理内存地址,从而编出精练而高效的程序 ...
- vue - 选项
1.计算属性(computed):主要是对原数据进行改造输出.改造输出:包括格式化数据(价格,日期),大小写转换,排序,添加符号 2.methods(methods):用于绑定html中的事件对应的方 ...
- 算法笔记_102:蓝桥杯练习 算法提高 快乐司机(Java)
目录 1问题描述 2 解决方案 1 问题描述 问题描述 "嘟嘟嘟嘟嘟嘟 喇叭响 我是汽车小司机 我是小司机 我为祖国运输忙 运输忙" 这是儿歌“快乐的小司机”.话说现在当司机光 ...
- python求pi的方法
来自 #_*_ coding=utf-8 *_* ## {{{ http://code.activestate.com/recipes/578130/ (r5) def pi(places=10): ...
- 05-hibernate注解-多对一单向外键关联
多对一单向外键 1,多方持有一方的引用,比如:多个学生对应一个班级(多对一) 2,@ManyToOne(cascade={CascadeType.ALL}, fetch=FetchType.EAGE ...
- 深入annotation
目标: 掌握@Target注释 掌握@Document注释 掌握@inherited注释 之前定义的annotation,如果没有明确声明,可以在任何地方使用: package 类集; @MyDefa ...