USACO Runaround Numbers
题目大意:问最近的比n大的循环数是多少
思路:第n遍暴力大法好
/*{
ID:a4298442
PROB:runround
LANG:C++
}
*/
#include<iostream>
#include<fstream>
#define maxn 500
using namespace std;
ifstream fin("runround.in");
ofstream fout("runround.out");
//#define fin cin
//#define fout cout
int runround(long long x)
{
int digital[maxn]={},num[maxn],h=;
bool visit[maxn]={},visit2[]={};
while(x!=)
{
digital[++h]=x%;
if(visit2[digital[h]]==)return ;
visit2[digital[h]]=;
if(digital[h]==)return ;
x/=;
}
for(int i=h;i>=;i--)num[i-]=digital[h-i+];
int pos=;
for(int i=;i<=h;i++)
{
visit[pos]=;
int u=num[pos];
pos=(u+pos)%h;
if(visit[pos]== && i!=h)return ;
if(i==h && pos!=)return ;
}
return ;
}
int main()
{
int n;
fin>>n;
for(long long i=n+;;i++)
{
if(runround(i))
{
fout<<i<<endl;
break;
}
}
return ;
}
USACO Runaround Numbers的更多相关文章
- USACO Runaround Numbers 模拟
根据题意的 Runaround 规则去找比当前数大的最近的一个 Runaround数字 模拟题~ Source code: /* ID: wushuai2 PROG: runround LANG: C ...
- USACO 2.2 Runaround Numbers
Runaround Numbers Runaround numbers are integers with unique digits, none of which is zero (e.g., 81 ...
- 洛谷P1467 循环数 Runaround Numbers
P1467 循环数 Runaround Numbers 89通过 233提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交 讨论 题解 最新讨论 暂时没有讨论 题目描述 循环数是 ...
- USACO Humble Numbers
USACO Humble Numbers 这题主要是两种做法,第一种是比较常(jian)规(dan)的-------------用pq(priority_queue)维护,每次取堆中最小值(小根堆) ...
- 【USACO 2.2】Runaround Numbers
找出第一个大于n的数满足:每一位上的数都不同,且没有0,第一位开始每次前进当前这位上的数那么多位,超过总位数就回到开头继续往前进,最后能不能每个位都到过一次且回到第一位,$n<10^9$. 暴力 ...
- USACO Section 2.2 循环数 Runaround Numbers
OJ:http://www.luogu.org/problem/show?pid=1467 #include<iostream> #include<vector> #inclu ...
- USACO Section 2.2: Runaround Numbers
简单题 /* ID: yingzho1 LANG: C++ TASK: runround */ #include <iostream> #include <fstream> # ...
- USACO Section2.2 Runaround Numbers 解题报告 【icedream61】
runround解题报告---------------------------------------------------------------------------------------- ...
- p1467 Runaround Numbers
直接搜就行. #include <iostream> #include <cstdio> #include <cmath> #include <algorit ...
随机推荐
- show processlist使用介绍
这个命令中最关键的就是state列,mysql列出的状态主要有以下几种: Checking table 正在检查数据表(这是自动的).Closing tables 正在将表中修改的数据刷新到磁盘中,同 ...
- JAVA的程序基本结构和数据类型
//源程序 Hello.java public class Hello { static String str ="Hello World"; public static void ...
- org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/home/index2", template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template "/home/index2", ...
- Scala 的list
9.1 使用列表 列表类型:跟数组一样,列表也是同质化的(homogeneous).即所有元素都要是同种类型. 列表结构:所有列表由两部分组成:Nil 和 ::(cons). 基本操作:主要有三个:h ...
- 判断NumLock键和CapsLock键是否被锁定
实现效果: 知识运用: AIP函数GetKeyState //针对已处理过的按键 在最近一次输入信息时 判断指定虚拟键的状态 intkey:预测试的虚拟键键码 实现代码: [DllImport(&qu ...
- Alfred的配置和使用
http://www.jianshu.com/p/f77ad047f7b0 Alfred:mac上的神兵利器,提升工作效率*n,快捷键:option + 空格.鉴于是看了池老师的<人生元编程 ...
- CPP-基础:C++中为什么需要一个头文件,一个cpp文件
把文件分成头文件和源文件完全是为了方便扩展和组织程序 这么说吧 我们可能会自定义很多函数 而这些函数分别会在不同的地方被调用 甚至有些时候我们需要把一堆函数打包起来一起调用 比如#include &q ...
- k8s framework
reference 1. k8s master framework master master 是k8s cluster运行着daemon服务:kube-apiserver, kube-schedul ...
- ewebeditor上传文件大小
做项目大家都少不了要跟html在线编辑器打交道,这里我把我的一些使用经验及遇到的问题发出来和大家交流一下. Ewebeditor使用说明:一.部署方式:1.直接把压缩目录中的文件拷贝到您的网站发布目录 ...
- rocketmq 命令示例
http://www.360doc.com/content/16/0111/17/1073512_527143896.shtml http://www.cnblogs.com/marcotan/p/4 ...