OJ:http://www.luogu.org/problem/show?pid=1467

#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int v[10],pv[64];
bool judge(long long x){
	vector<int> a,b;
	memset(v,0,sizeof(v));
	while(x>=10){
		a.push_back(x%10);
		if(v[x%10])
			return false;
		v[x%10]=1;
		x/=10;
	}
	if(v[x])
		return false;
	if(v[0])
		return false;
	b.push_back(x);
	for(int i=a.size()-1;i>=0;i--) b.push_back(a[i]);
	int p=0;
	memset(pv,0,sizeof(pv));
	for(int i=1;i<b.size();i++){
		if(pv[p]) return false;
		pv[p]=1;
		p+=b[p];
		p%=b.size();
	}
	return (p+b[p])%b.size()==0;
}
int main()
{
	long long n;
	cin>>n;
	while(!judge(++n));
	cout<<n;
	return 0;
}

  

USACO Section 2.2 循环数 Runaround Numbers的更多相关文章

  1. 洛谷P1467 循环数 Runaround Numbers

    P1467 循环数 Runaround Numbers 89通过 233提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交  讨论  题解 最新讨论 暂时没有讨论 题目描述 循环数是 ...

  2. USACO 2.2 Runaround Numbers

    Runaround Numbers Runaround numbers are integers with unique digits, none of which is zero (e.g., 81 ...

  3. USACO Section 2.2: Runaround Numbers

    简单题 /* ID: yingzho1 LANG: C++ TASK: runround */ #include <iostream> #include <fstream> # ...

  4. USACO Runaround Numbers 模拟

    根据题意的 Runaround 规则去找比当前数大的最近的一个 Runaround数字 模拟题~ Source code: /* ID: wushuai2 PROG: runround LANG: C ...

  5. USACO Section2.2 Runaround Numbers 解题报告 【icedream61】

    runround解题报告---------------------------------------------------------------------------------------- ...

  6. USACO Runaround Numbers

    题目大意:问最近的比n大的循环数是多少 思路:第n遍暴力大法好 /*{ ID:a4298442 PROB:runround LANG:C++ } */ #include<iostream> ...

  7. 【USACO 2.2】Runaround Numbers

    找出第一个大于n的数满足:每一位上的数都不同,且没有0,第一位开始每次前进当前这位上的数那么多位,超过总位数就回到开头继续往前进,最后能不能每个位都到过一次且回到第一位,$n<10^9$. 暴力 ...

  8. USACO Section 1.3 题解 (洛谷OJ P1209 P1444 P3650 P2693)

    usaco ch1.4 sort(d , d + c, [](int a, int b) -> bool { return a > b; }); 生成与过滤 generator&& ...

  9. USACO Section 3.3: Riding the Fences

    典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...

随机推荐

  1. HDU3516 树的构造

    题目大意:平面上有n个点,构成一个单调递减的序列.即对于任意的i<j,有xi<xj,yi>yj.现在要用一棵树连接这n个点.树边为有向边,只能向右或向上.求最小的权值. 分析:本题其 ...

  2. HDU3415

    题目大意: 给出一个有N个数字(-1000..1000,N<=10^5)的环状序列,找出一个长度不大于k的连续子序列,使其和最大. 分析: 我们可以将环状序列从某处切开,变成一行,然后复制前n- ...

  3. 如何把SQLServer数据库从高版本降级到低版本?

    http://blog.csdn.net/dba_huangzj/article/details/7952403 由于目前还广泛使用着SQLServer2000,很多公司又想使用新的SQLServer ...

  4. C#将字符串转换为整型的三种方法的总结

    在C#中,要将一个字符串或浮点数转换为整数,基本上有三种方法: (1)使用强制类型转换:(int)浮点数 (2)使用Convert.ToInt32(string) (3)使用int.Parse(str ...

  5. Redis内存使用优化与存储(转)

    Redis常用数据类型 Redis最为常用的数据类型主要有以下五种: String Hash List Set Sorted set 在具体描述这几种数据类型之前,我们先通过一张图了解下Redis内部 ...

  6. 如何获取客户端IP、操作系统、浏览器

    request.getRemoteAddr();//获取IP request.getHeader("User-Agent");//获取操作系统信息.浏览器信息. protected ...

  7. [Android Exception 1A] -com.android.volley.NoConnectionError: java.io.InterruptedIOException

    - ::-/com.tongyan.tutelage W/System.err: com.android.volley.NoConnectionError: java.io.InterruptedIO ...

  8. zabbix安装,关闭SELinux

    一.缘由 在安装zabbix的时候,按照官网的Zabbix Manual一路跑下来,zabbix的dashboard提示:zabbix server is not running the inform ...

  9. C++ operator 知识点 2

    http://blog.csdn.net/szlanny/article/details/4295854 operator它有两种用法,一种是operator overloading(操作符重载),一 ...

  10. 如何给ubuntu虚拟机添加硬盘和快捷键(转载)

    From:http://os.51cto.com/art/201003/188721.htm 刚开始建立Ubuntu虚拟机时间,把容量设置为8Gb 了,然后没过几天就没有地方了,郁闷!查了一下,有几种 ...