Contest2037 - CSU Monthly 2013 Oct (Problem J: Scholarship)
http://acm.csu.edu.cn/OnlineJudge/problem.php?cid=2037&pid=9
【题解】:
这题卡了一下,卡在负数的情况,负数输出 0
这题主要找到一个个相邻重复的位置,然后加1上去,看是否进位,直到满足条件为止
【code】:
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std; void inttostr(int n,char *str)
{
int cnt=;
while(n)
{
str[cnt]=n%+'';
n/=;
cnt++;
}
str[cnt]='\0';
// cout<<str<<endl;
int i;
for(i=;i<cnt/;i++)
{
swap(str[i],str[cnt-i-]);
}
} int CheckRight(char *str)
{
int len = strlen(str);
int i;
for(i=;i<len;i++)
{
if(str[i]==str[i-]&&str[i]!='')
{
return i;
}
}
return -;
} int main()
{
int n;
scanf("%d",&n);
while(n--)
{
int m;
scanf("%d",&m);
if(m<)
{
printf("%d\n",);
continue;
}
if(m<)
{
printf("%d\n",m+);
continue;
}
char str[];
inttostr(m,str);
if(CheckRight(str)==-)
{
m++;
inttostr(m,str);
}
while()
{
int id = CheckRight(str);
if(id==-)
{
break;
}
else
{
int len = strlen(str);
int i,j;
str[id]++;
for(i=id+;i<len;i++)
{
str[i]='';
}
for(i=id;i>=;i--)
{
if(str[i]>'')
{
str[i]='';
if(i>)
str[i-]++;
else
{
for(j=len+;j>;j--)
{
str[j]=str[j-]; }
str[j] = '';
}
}
}
}
}
printf("%s\n",str);
}
return ;
}
Contest2037 - CSU Monthly 2013 Oct (Problem J: Scholarship)的更多相关文章
- Contest2037 - CSU Monthly 2013 Oct (problem F :ZZY and his little friends)
http://acm.csu.edu.cn/OnlineJudge/problem.php?cid=2037&pid=5 [题解]: 没想通这题暴力可以过.... [code]: #inclu ...
- Contest2037 - CSU Monthly 2013 Oct (problem B :Scoop water)
http://acm.csu.edu.cn/OnlineJudge/problem.php?cid=2037&pid=1 [题解]:卡特兰数取模 h(n) = h(n-1)*(4*n-2)/( ...
- Contest2037 - CSU Monthly 2013 Oct (problem D :CX and girls)
[题解]: 最短路径问题,保证距离最短的同时,学妹权值最大,哈哈 [code]: #include<iostream> #include<queue> #include< ...
- Contest2037 - CSU Monthly 2013 Oct (problem A :Small change)
[题解]:二进制拆分 任意一个整数都可以拆分成 2^0 + 2^1 + 2^2 + 2^3 + ....+ m [code]: #include <iostream> #include & ...
- Contest2037 - CSU Monthly 2013 Oct(中南大学2013年10月月赛水题部分题解)
Problem A: Small change 题解:http://www.cnblogs.com/crazyapple/p/3349469.html Problem B: Scoop water 题 ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem J
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, ...
- ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)
题目链接 ZOJ Monthly, March 2018 Problem G 题意 给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...
- ZOJ 4009 And Another Data Structure Problem(ZOJ Monthly, March 2018 Problem F,发现循环节 + 线段树 + 永久标记)
题目链接 ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. ...
- 实验12:Problem J: 动物爱好者
#define null ""是用来将字符串清空的 #define none -1是用来当不存在这种动物时,返回-1. 其实这种做法有点多余,不过好理解一些. Home Web B ...
随机推荐
- poj3264
Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 45777 Accepted: 21499 ...
- 原生js 实现的瀑布流
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- 我的jquery之路
不知不觉jquery已经看完了. 以前不知道jquery是什么,现在依然不是很清晰.或许学习的结果就是这样吧,忘记你所学的.
- Spring(3.2.3) - Beans(11): depends-on
大多数情况下,Bean 之间的依赖非常直接:被依赖的 Bean 作为属性.在 XML 配置文件中最常见的就是使用 <ref/> 元素.在一些特殊情况下,Bean 之间的依赖不够直接.比如, ...
- Remote Desktop Connection Manager介绍
Remote Desktop Connection Manager (RDCMan) 是微软Windows Live体验团队的主要开发者 Julian Burger开发的一个远程桌面管理工具.简称为R ...
- 剑指offer_面试题11 数值的整数次方_考察代码的完整性
测试通过代码: package t0825; public class Power { public static void main(String[] args){ System.out.print ...
- 个人实验记录之EIGRP基本配置
一.EIGRP的基本配置 1(1).进入接口配置IP R1(config)#inter s1/0 R1(config-if)#ip address 200.1.1.1 255.255.255.0 R1 ...
- OC5_复合类的内存管理
// // Person.h // OC5_复合类的内存管理 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhan ...
- eclipse注册码生成,在eclipse3.3.x上测试可用
这段时间刚加入一个新的项目组,项目组使用的Flex框架. 开发工具由项目组统一提供,使用的是Eclipse 3.3.0,里面包含了其他开发人员集成上去的许多插件,个人感觉比较实用.但是这个版本Ecli ...
- VS2010远程调试
1, A:调试机. B:远端被调试机. 2, 从A机的VS2010的安装目录里面,找到../Remote Debugger文件,复制到B机. 3, 启动B机上复制过来的目录下的msvsmon.exe ...