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 ...
随机推荐
- IOSButton自定义
+ (APCCustomBackButton *)customBackButtonWithTarget:(id)aTarget action:(SEL)anAction tintColor:(UICo ...
- Java中常见编码格式及乱码解决方法
一:设置编码格式 1.JSP文件 charset=UTF-8 的作用是指定JSP向客户端输出的编码方式为"UTF-8",pageEncoding="UTF-8" ...
- Invalid bound statement (not found): com.ros.dao.LogMapper.insert
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.ros.dao.LogMapp ...
- winform中让显示的图片覆盖到父窗体保持父窗体的不可选中的状态,且任务栏中不会显示子窗体的任务选项
要求:为父窗体添加一个类似于加载等待的功能,当窗体点击备份时弹出且覆盖掉窗体 问题一产生:当为弹窗添加控件时,form.show();导致窗体卡死,控件变得透明化; 问题一分析:当窗体show();之 ...
- python基础一 day10(2)
复习: # 三元运算符# 接收结果的变量 = 条件为真的结果 if 条件 else 条件为假的结果# 接收结果的变量 = “真结果” if 条件 else “假结果”## 命名空间 和 作用域# 三种 ...
- 使用prelu
一个使用方式:http://blog.csdn.net/xg123321123/article/details/52610919 还有一种是像relu那样写,我就是采用的这种方式,直接把名字从relu ...
- Python3 try-except、raise和assert解析
Python3 try-except.raise和assert解析 一.说明 关于异常捕获try-except:在学java的时候就被教育异常捕获也是java相对c的一大优点,几年下来多少也写了些代码 ...
- 开源 java 电商系统
shop++是基于spring.springmvc等主流框架开发,参考资料比较全面,上手容易: 比 javashop 代码可读性好. 适合二次开发 6.broadleaf基于spring.Spring ...
- Xcode 6 创建 Objective-C category
1. Command + N 2. 选择 iOS - Source - Objective-C File 3.File Type 选择 Category,Class 填基于的类名,File填扩展的名
- 【单调栈 动态规划】bzoj1057: [ZJOI2007]棋盘制作
好像还有个名字叫做“极大化”? Description 国际象棋是世界上最古老的博弈游戏之一,和中国的围棋.象棋以及日本的将棋同享盛名.据说国际象棋起源 于易经的思想,棋盘是一个8*8大小的黑白相间的 ...