题意简单,中文题目

方法:对于一个数 从左往右找相同的数 ,有就改变靠右的,同时把该数的右边全置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. SQLserver的存储过程

    存储过程 [Create是创建存储过程,alter是更改.改变存储过程] [在第一次写存储过程时用create,若修改存储过程程序之后,则alter替换create再执行] [在数据库中begin   ...

  2. Using LINQ Group By and String.Join() / Aggregate() in Entity Framework 3.5

    linq to sql 的时候,有时候需要用到 先group  然后来个 aggregate 串连一下值, 但会总会出错,说不识别 aggregate 或者 string.join 方法 搜遍网络 一 ...

  3. 操作Excel导入的问题(转)

    当Excel导入成为需要时,之前的导出Excel为html方式的方法就受阻了,于是,需要开始新的百度与google来解决问题. 前提为OLEDB+Excel. 根据需求,多数是对于表的数据的导入.于是 ...

  4. cplusplus解析

    经常在头文件包含代码里面看到如下代码 #ifndef MAC_API_H #define MAC_API_H #ifdef __cplusplus extern "C"{ #end ...

  5. qml实现窗口拖动

    在去掉窗口标题栏后窗口会失去鼠标拖动效果,所以需要自己添加拖动效果. 实现代码: ApplicationWindow {     id: mainWindow     visible: true    ...

  6. ASP.NET Web API标准的“管道式”设计

    详见:http://www.cnblogs.com/artech/p/asp-net-web-api-pipeline.html http://www.codeproject.com/Articles ...

  7. mysql中limit的用法实例解析

    mysql中limit的用法解析. 在mysql中,select * from table limit m,n.其中m是指记录开始的index,从0开始,n是指从第m条开始,取n条. 例如: mysq ...

  8. Pandas简易入门(二)

    目录:     处理缺失数据     制作透视图     删除含空数据的行和列     多行索引     使用apply函数   本节主要介绍如何处理缺失的数据,可以参考原文:https://www. ...

  9. UartDma工作方式

    一.初始化 1.初始化串口,时钟 MX_USART1_UART_Init(); 串口时钟初始化为内部时钟 PeriphClkInit.Usart1ClockSelection = RCC_USART1 ...

  10. oracle中的dual表详解

    oracle中的dual表详解 1.DUAL表的用途 Dual 是 Oracle中的一个实际存在的表,任何用户均可读取,常用在没有目标表的Select语句块中 --查看当前连接用户 SQL> s ...