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

  1. 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 ...

  2. 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)/( ...

  3. Contest2037 - CSU Monthly 2013 Oct (problem D :CX and girls)

    [题解]: 最短路径问题,保证距离最短的同时,学妹权值最大,哈哈 [code]: #include<iostream> #include<queue> #include< ...

  4. Contest2037 - CSU Monthly 2013 Oct (problem A :Small change)

    [题解]:二进制拆分 任意一个整数都可以拆分成 2^0 + 2^1 + 2^2 + 2^3 + ....+ m [code]: #include <iostream> #include & ...

  5. Contest2037 - CSU Monthly 2013 Oct(中南大学2013年10月月赛水题部分题解)

    Problem A: Small change 题解:http://www.cnblogs.com/crazyapple/p/3349469.html Problem B: Scoop water 题 ...

  6. 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, ...

  7. ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)

    题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...

  8. ZOJ 4009 And Another Data Structure Problem(ZOJ Monthly, March 2018 Problem F,发现循环节 + 线段树 + 永久标记)

    题目链接  ZOJ Monthly, March 2018 Problem F 题意很明确 这个模数很奇妙,在$[0, mod)$的所有数满足任意一个数立方$48$次对$mod$取模之后会回到本身. ...

  9. 实验12:Problem J: 动物爱好者

    #define null ""是用来将字符串清空的 #define none -1是用来当不存在这种动物时,返回-1. 其实这种做法有点多余,不过好理解一些. Home Web B ...

随机推荐

  1. Web Service 一些对外公开的网络服务接口

    商业和贸易: 1.股票行情数据 WEB 服务(支持香港.深圳.上海基金.债券和股票:支持多股票同时查询) Endpoint: http://webservice.webxml.com.cn/WebSe ...

  2. android手机中图片的拖拉及浏览功能

    配置文件 activity_main.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/andro ...

  3. 160多个android开源代码汇总

    第一部分 个性化控件(View) 主要介绍那些不错个性化的View,包括ListView.ActionBar.Menu.ViewPager.Gallery.GridView.ImageView.Pro ...

  4. kettle

    Kettle(中文名称叫水壶)是一款ETL工具,纯java编写,可以在Window.Linux.Unix上运行,绿色无需安装,数据抽取高效稳定.Kettle家族包括4个产品:Spoon.Pan.CHE ...

  5. CSS常用中文字体、字号

    字体(font-family): 新细明体:PMingLiU 细明体:MingLiU 标楷体:DFKai-SB 黑体:SimHei 宋体:SimSun 新宋体:NSimSun 仿宋:FangSong  ...

  6. mount loop最大数的调整

    mount: could not find any free loop device vi /etc/modules.conf Add "options loop max_loop=64&q ...

  7. Android 开机自启动应用

    Android启动时,会发出一个系统广播 ACTION_BOOT_COMPLETED,它的字符串常量表示为 “android.intent.action.BOOT_COMPLETED” 开机自启动程序 ...

  8. WMI查看电脑信息,devenv管理自己的解决方案

    最近把公司用的电脑重装了一下,期间用到了驱动精灵,驱动精灵把电脑的全方面信息都显示出来了,让人有种一目了然的感觉,为什么我不自己也写个呢?虽然显示的数据不一定有驱动精灵全单至少是我自己写的,不是吗? ...

  9. Ajax和JSON基础

    Ajax (核心是XMLHttpRequest对象) 1.XMLHttpRequest对象: request=new XMLHttpRequest()  支持Firefox opera Safari  ...

  10. Xml 学习二

    使用PHPDOM模型操作XML XML的树状结构: s 1.xml文档 1.1.创建DOM树 //创建DOM树$M = new DOMDocument('1.0','utf-8');   1.2.加载 ...