题意简单,中文题目

方法:对于一个数 从左往右找相同的数 ,有就改变靠右的,同时把该数的右边全置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. Cocos2d-x中Vector<T>容器以及实例介绍

    Vector<T> 是Cocos2d-x 3.x推出的列表容器,因此它所能容纳的是Ref及子类所创建的对象指针,其中的T是模板,表示能够放入到容器中的类型,在Cocos2d-x 3.x中T ...

  2. SwithAndActivity 选择开关和活动指示

    ////  ViewController.m//  SwithAndActivity////  Created by qianfeng on 15/9/21.//  Copyright (c) 201 ...

  3. WaitForSingleObject用法

    对应函数 编辑 VC声明 DWORD WaitForSingleObject( HANDLE hHandle, DWORD dwMilliseconds );   参数 编辑 hHandle[in]对 ...

  4. SQL server 常见用法记录

        -- ============================================= -- Author:                tanghong -- Create da ...

  5. open_clientfd(char* hostname,int port)和open_listenfd(int port)

    #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h&g ...

  6. Unity编程回忆录之控制物体移动

    最新心血来潮,然后开始学习Unity3D游戏开发引擎,对于一个主流的跨平台3D游戏开发引擎,我已经深深的为他着迷了,于是果断的开始学习这个引擎,而且刚刚预装的游戏引擎最新版中4.3版本已经开始原生支持 ...

  7. 《编写高质量代码-Web前端开发修改之道》笔记--第三章 高质量的HTML

    本章内容: 标签的语义 为什么要使用语义化标签 如何确定你的标签是否语义良好 常见模块你真的很了解吗 标签的语义 HTML标签的设计都是有语义考虑的,部分标签的中文翻译图示及本章内容参看:3.1 标签 ...

  8. HTML5 drag & drop 拖拽与拖放简介

    DataTransfer 对象:退拽对象用来传递的媒介,使用一般为Event.dataTransfer. draggable 属性:就是标签元素要设置draggable=true,否则不会有效果,例如 ...

  9. 一个不错的图片滑动展示插件 anythingslider

    一个不错的图片http://css-tricks.com/anythingslider-jquery-plugin/ DEMO演示: http://css-tricks.github.io/Anyth ...

  10. WPF 中 TreeListView 的使用

    前段时间在项目开发中需要用 TreeListView 的功能,于是在网上狂搜一通,倒也找到了几个小例子,但还是满足不了我简单的要求,由于时间紧也只能折中凑合着用了.最近时间比较充裕,把其中的例子整理一 ...