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 ...
随机推荐
- setuid
-r-s--x--x #s就是setuid,仅可用在二进制文件,对目录设置无效
- 你不知道的HTTP之HTTPS
确保web安全的HTTPS HTTPS=HTTP+ 加密 + 认证 + 完整性保护 1.加密: 1)通信的加密 所谓互联网,是由能连通到全世界的网络组成的.无论世界哪个角 落的服务器在和客户端通信时, ...
- codevs 1097 校门外的树 2005年NOIP全国联赛普及组 (线段树)
时间限制: 1 s 空间限制: 128000 KB 题目等级 : 白银 Silver 题目描述 Description 某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是1米.我们可 ...
- dataSource' defined in class path resource [org/springframework/boot/autocon
spring boot启动的时候抛出如下异常: dataSource' defined in class path resource [org/springframework/boot/autocon ...
- urlrrtrieve()实例_下载微博短视频
1.确定目标 在微博页面找一想要下载的短视频,通过审查元素找到视频的url. 如://f.us.sinaimg.cn/00150tBNlx07l0qjoSJi01040201m7z90k010.mp4 ...
- input提示文字;placeholder字体修改
在很多网站上我们都看到input输入框显示提示文字,让我们一起来看看如果在input输入框中显示提示文字.我们只需要在<input>标签里添加:placeholder="提示文字 ...
- Linux系统分区 进程管理 软件包安装
对于一块新的磁盘来说,系统能够使用需要有分区.格式化文件系统.挂载等主要操作,下面通过命令的方式对一块磁盘进行操作. 一. Linux系统分区 1.1 在虚拟机开机前选择虚拟机配置,添加一个新的SCS ...
- 【Codeforces Rockethon 2014】Solutions
转载请注明出处:http://www.cnblogs.com/Delostik/p/3553114.html 目前已有[A B C D E] 例行吐槽:趴桌子上睡着了 [A. Genetic Engi ...
- 7.逻辑运算 and or not
1)优先级 ()> not > and > o r and:真真为真,真假为假 ,假假为假 or:真真为真,真假为真,假假为假 print(2 > 1 and 1 < ...
- netstat Recv-Q和Send-Q详解
http://blog.csdn.net/sjin_1314/article/details/9853163 通过netstat -anp可以查看机器的当前连接状态: Active Interne ...