USACO Section 2.2 循环数 Runaround Numbers
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的更多相关文章
- 洛谷P1467 循环数 Runaround Numbers
P1467 循环数 Runaround Numbers 89通过 233提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交 讨论 题解 最新讨论 暂时没有讨论 题目描述 循环数是 ...
- USACO 2.2 Runaround Numbers
Runaround Numbers Runaround numbers are integers with unique digits, none of which is zero (e.g., 81 ...
- USACO Section 2.2: Runaround Numbers
简单题 /* ID: yingzho1 LANG: C++ TASK: runround */ #include <iostream> #include <fstream> # ...
- USACO Runaround Numbers 模拟
根据题意的 Runaround 规则去找比当前数大的最近的一个 Runaround数字 模拟题~ Source code: /* ID: wushuai2 PROG: runround LANG: C ...
- USACO Section2.2 Runaround Numbers 解题报告 【icedream61】
runround解题报告---------------------------------------------------------------------------------------- ...
- USACO Runaround Numbers
题目大意:问最近的比n大的循环数是多少 思路:第n遍暴力大法好 /*{ ID:a4298442 PROB:runround LANG:C++ } */ #include<iostream> ...
- 【USACO 2.2】Runaround Numbers
找出第一个大于n的数满足:每一位上的数都不同,且没有0,第一位开始每次前进当前这位上的数那么多位,超过总位数就回到开头继续往前进,最后能不能每个位都到过一次且回到第一位,$n<10^9$. 暴力 ...
- 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&& ...
- USACO Section 3.3: Riding the Fences
典型的找欧拉路径的题.先贴下USACO上找欧拉路径的法子: Pick a starting node and recurse on that node. At each step: If the no ...
随机推荐
- Node.js 相关资料网站汇总
地址:https://cnodejs.org/ nodejs中文网:http://nodejs.cn/ nodejs中文网:http://www.nodejs.net/ 相关API地址:http:// ...
- activiti自定义流程之整合(一):整体环境配置
结合之前所说的自定义流程的思路,分别是后台.前台.整合,之前的内容也分别进行了相关的练习和尝试,现在就该到了最后的整合了,依旧是以实现功能为目的,细节暂且不去管他. 因为我们实际项目后端用的是spri ...
- 【wp之二 页面布局】
1. panoramic全景视图 新建工程选择:Windows Phone Panorama Application 相当于用放大镜看报纸的感觉.用一张图片作为背景. 2.pivot透视视图
- Java AES加密
Java AES 加密 加密 /** * * @description 加密 * * @param content 需要加密的内容 * @param password 加密密码 * @return * ...
- (C# ) 解析XML。
解析XML有很多方法,之前用专门写的XMLProcess 或XMLHelper 解析类.其实有个较简单的解析就是用Linq查询. 例如有如下XML <?xml version="1.0 ...
- java数组初始化的三种方式
//第一种 int[] is= new int[3]; is[0]=1; is[1]=2; is[2]=3; //第二种 int[] is2= {1,2,3}; //第三种 int[] is3= ...
- windows环境下 生成git公钥和私钥
windows环境下 生成公钥和私钥 上传代码到远程仓库的时候需要秘钥进行验证是否本人上传的.打开Git目录下的Git Bash 输入ssh-keygen,回车 可直接不输入路径,使用默认路径(c/U ...
- U8Bom查询
select temp.*,Inventory.cInvCode,Inventory.cInvName,Inventory.cInvStd from ( select b.InvCode as 'PI ...
- bug_ _fragment的1
========= 2 fragment小结 ???? ======== 1 fragment:java.lang.IllegalStateException: Can not perf ...
- .NET 文件相关的所有操作
public static class FileSystemHelper { #region 检测指定目录是否存在 /// <summary> /// 检测指定目录是否存在 /// < ...