题意简单,中文题目

方法:对于一个数 从左往右找相同的数 ,有就改变靠右的,同时把该数的右边全置0

注意!!!!n<0!!!

 /*

 */
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long int64;
//typedef __int64 int64;
typedef pair<int64,int64> PII;
#define MP(a,b) make_pair((a),(b))
const int inf = 0x3f3f3f3f;
const double pi=acos(-1.0);
const int dx[]={,-,,};
const int dy[]={,,,-};
const double eps = 1e-;
const int maxm = ;
const int maxn = ; int num[ maxn ];
int64 n ; void Solve( int cnt ){
int temp = ;
int pos = -;
for( int i=;i<cnt;i++,temp *= ){
if( i+<cnt && num[i]== && num[i+]== ) continue;
if( num[i]==num[i+] ){
n += temp;
pos = i;
//printf("pos = %d\n",pos);
//printf("i = %d\n",i);
if( pos> ){
int tt = ;
while( ){
n /= ;
pos--;
tt *= ;
if( pos== ) break;
}
n *= tt;
} if( num[i]== ){
int64 nn = n;
int cc = ;
while( nn ){
num[ cc++ ] = nn%;
nn /= ;
}
}
}
}
//printf("pos = %d\n",pos);
} bool Judge( int n ){
int cnt = ;
int64 nn = n;
while( nn ){
num[ cnt++ ] = nn%;
nn /= ;
}
bool flag = true;
for( int i=;i<cnt;i++ ){
if( i+<cnt && num[i]== && num[i+]== ) continue;
if( num[i]!=num[i+] ) {}
else {
flag = false;
break;
}
}
if( flag==true )
return true;
Solve( cnt );
return false;
} int main(){
int T;
scanf("%d",&T);
while( T-- ){
//scanf("%d",&n);
cin>>n;
if( n< ){
cout<<""<<endl;
continue;
}
n ++;
memset( num,,sizeof( num ) );
while( ){
if( Judge(n)==true ) break;
}
//printf("%d\n",n);
cout<<n<<endl;
}
return ;
}

CSU1327+贪心+模拟的更多相关文章

  1. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

  2. 贪心+模拟 ZOJ 3829 Known Notation

    题目传送门 /* 题意:一串字符串,问要最少操作数使得成为合法的后缀表达式 贪心+模拟:数字个数 >= *个数+1 所以若数字少了先补上在前面,然后把不合法的*和最后的数字交换,记录次数 岛娘的 ...

  3. CodeForces ---596B--Wilbur and Array(贪心模拟)

    Wilbur and Array Time Limit: 2000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Su ...

  4. UVA 10714 Ants 蚂蚁 贪心+模拟 水题

    题意:蚂蚁在木棍上爬,速度1cm/s,给出木棍长度和每只蚂蚁的位置,问蚂蚁全部下木棍的最长时间和最短时间. 模拟一下,发现其实灰常水的贪心... 不能直接求最大和最小的= =.只要求出每只蚂蚁都走长路 ...

  5. CodeForces 797C Minimal string:贪心+模拟

    题目链接:http://codeforces.com/problemset/problem/797/C 题意: 给你一个非空字符串s,空字符串t和u.有两种操作:(1)把s的首字符取出并添加到t的末尾 ...

  6. CodeForces - 730A 贪心+模拟

    贪心策略: 1.只有一个最大值,选着第二大的一起参加比赛减分. 2.有奇数个最大值,选择三个进行比赛. 3.偶数个最大值,选择两个进行比赛. 为什么不把最大值全部选择? 因为最多只能选五个,有可能选择 ...

  7. (贪心 模拟?) codeVs1098 均分纸牌

    题目描述 Description 有 N 堆纸牌,编号分别为 1,2,…, N.每堆上有若干张,但纸牌总数必为 N 的倍数.可以在任一堆上取若于张纸牌,然后移动. 移牌规则为:在编号为 1 堆上取的纸 ...

  8. UVA 11776 - Oh Your Royal Greediness! - [贪心/模拟]

    题目链接:https://cn.vjudge.net/problem/UVA-11776 题意: 给出数字n(0<=n<=1000),代表有n个农民,接下来有n行,每行两个数字S和E代表这 ...

  9. Population Size CodeForces - 416D (贪心,模拟)

    大意: 给定$n$元素序列$a$, 求将$a$划分为连续的等差数列, 且划分数尽量小. $a$中的$-1$表示可以替换为任意正整数, 等差数列中必须也都是正整数. 贪心策略就是从前到后尽量添进一个等差 ...

随机推荐

  1. MINUS,INTERSECT,UNION浅析

    转载:http://blog.csdn.net/gan690416372/article/details/5012397 SQL语句中的三个关键字:MINUS(减去),INTERSECT(交集)和UN ...

  2. 版本控制工具--GIT 基本命令(1)

    一.安装GIT,在官网上下载安装即可(下面模拟环境是window7) 二.基本操作: 1.创建GIT库: ①先使用mkdir命令创建一个空目录,再使用git init将该目录变成GIT库,会在该目录下 ...

  3. PHP取二进制文件头快速判断文件类型

    <?php /*文件扩展名说明 *7173 gif *255216 jpg *13780 png *6677 bmp *239187 txt,aspx,asp,sql *208207 xls.d ...

  4. Limit参数优化MySQL查询的方法

    在做一些查询时,总希望能避免数据库引擎做全表扫描,因为全表扫描时间长,而且其中大部分扫描对客户端而言是没有意义的.那么,在mysql中有那些方式是可以避免全表扫面?除了通过使用索引列或分区等方式来进行 ...

  5. location跳转和header跳转的区别

    1:header("location:url") 跳转之前不能有任何输出,如果想在header之前有输出,则要修改php.ini文件.具体 output_handler =mb_o ...

  6. WPF中的WebBrowser

    MainWindow.xaml.cs //新窗口事件 { Uri uri = new Uri(textBox_uri.Text); System.Windows.Forms.Integration.W ...

  7. poj 3415 Common Substrings 后缀数组+单调栈

    题目链接 题意:求解两个字符串长度 大于等于k的所有相同子串对有多少个,子串可以相同,只要位置不同即可:两个字符串的长度不超过1e5; 如 s1 = "xx" 和 s2 = &qu ...

  8. ISBN

    问题描述 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字.1位识别码和3位分隔符,其规定格式如“x-xxx-xxxxx-x”,其中符号“-”是分隔符(键盘上的减号),最后一位 ...

  9. seo 优化 仅针对 来拍呀www.laipaiya.com(一)

    加入百度统计代码:http://tongji.baidu.com/ 查看百度统计优化分析->seo建议 对每个页面的meta标签做修改 首页 title :来拍呀 - | 折扣好房你就来拍呀 k ...

  10. ORA-15025: could not open disk 处理

    刚才下班回家的路上,接到客户的电话:"回家了吗?我们这边的一套RAC库有个节点有问题哦,一直刷异常,一下子就把磁盘弄满了,我现在停掉了那个节点了.从日志上看好像跟权限有关,现在还有个实例跑着 ...