/*
ID:kevin_s1
PROG:runround
LANG:C++
*/ #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <list>
#include <cmath> using namespace std;
//直接枚举就可以 //gobal variable====
long long M;
int num[100];
int num_size; int hash[10];
int hash1[10];
//================== //function==========
int init(long long i){
int x = 1;
while(i != 0){
num[x++] = i % 10;
i = i / 10;
}
x--;
for(int i = 1; i <= x/2; i++){
int tmp = num[i];
num[i] = num[x - i + 1];
num[x - i + 1] = tmp;
}
return x;
} bool judge(long long x){
for(int i = 1; i <= num_size; i++){
hash1[num[i]]++;
if(hash1[num[i]] > 1 || num[i] == 0){
return false;
}
}
int j = 1;
for(int i = 1; i <= num_size; i++){
int bit = num[j];
j = j + bit;
if(j > num_size && (j % num_size) != 0){
j = j % num_size;
}
if(j > num_size && (j % num_size) == 0){
j = num_size;
}
if(hash[j] == 1){
return false;
}
hash[j] = 1;
}
bool flag = true;
if(j != 1)
flag = false;
for(int i = 1; i <= num_size; i++){
if(hash[i] == 0){
flag = false;
break;
}
}
return flag;
} //================== int main(){
freopen("runround.in","r",stdin);
freopen("runround.out","w",stdout);
cin>>M;
memset(num, 0, sizeof(num));
memset(hash, 0, sizeof(hash));
memset(hash1, 0, sizeof(hash1));
M++;
num_size = init(M);
while(!judge(M)){
M++;
memset(num, 0, sizeof(num));
memset(hash, 0, sizeof(hash));
memset(hash1, 0, sizeof(hash1));
num_size = init(M);
}
cout<<M<<endl;
return 0;
}

USACO runaround的更多相关文章

  1. USACO Runaround Numbers 模拟

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

  2. USACO Runaround Numbers

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

  3. USACO 2.2 Runaround Numbers

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

  4. 【USACO 2.2】Runaround Numbers

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

  5. USACO Section 2.2 循环数 Runaround Numbers

    OJ:http://www.luogu.org/problem/show?pid=1467 #include<iostream> #include<vector> #inclu ...

  6. USACO Section 2.2: Runaround Numbers

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

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

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

  8. 洛谷P1467 循环数 Runaround Numbers

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

  9. Luogu USACO Training 刷水记录

    开个坑记录一下刷USACO的Training的记录 可能会随时弃坑 只有代码和做法简述 可能没有做法简述 [USACO1.1]你的飞碟在这儿Your Ride Is He… 模拟,细节已忘 #incl ...

随机推荐

  1. UI组件之AdapterView及其子类(三)Spinner控件具体解释

    Spinner提供了从一个数据集合中高速选择一项值的办法. 默认情况下Spinner显示的是当前选择的值.点击Spinner会弹出一个包括全部可选值的dropdown菜单或者一个dialog对话框,从 ...

  2. node generator 模仿co

    exports.run = function(fn ){ return function(onDone){ function thunk(tfn , ctx){ return function(sql ...

  3. 软件測试、ios中的測试概念以及步骤

    软件測试: 软件測试的目标是应该服务于软件项目的目标,能够通过建议反馈使用更加高效的方法和工具,提升软件开发效率以及软件开发质量.同一时候还能够通过过一些手段,更早.更快.很多其它地发现缺陷.从容减少 ...

  4. Rose2003执行出现 -2147417848 (80010108)&#39;:Automation 错误

    上篇博客在结尾的时候.我提到了Ration Rose2003执行出现"-2147417848 (80010108)':Automation错误"的问题.今天这篇博客就来介绍一下怎样 ...

  5. Ruby学习笔记(二)——从管道读取数据

    在对文件名修改后,今天又给自己出了新的难题,想从实验结果中提取数据,并将其作为文件夹的名称.其中,比赛的主办方提供的评估算法是用perl写的,因此读取实验结果最为简单的想法自然是使用管道命令,即 ./ ...

  6. 杂项-Java:Spring

    ylbtech-杂项-Java:Spring Spring是一个开放源代码的设计层面框架,他解决的是业务逻辑层和其他各层的松耦合问题,因此它将面向接口的编程思想贯穿整个系统应用.Spring是于200 ...

  7. 23.QFile遍历

    #include "mainwindow.h" #include <QApplication> #include <QDebug> #include < ...

  8. C# 正则表达式

    C# 正则表达式 正则表达式 是一种匹配输入文本的模式..Net 框架提供了允许这种匹配的正则表达式引擎.模式由一个或多个字符.运算符和结构组成. 定义正则表达式 下面列出了用于定义正则表达式的各种类 ...

  9. User_Login_Register_Shopping+装饰器 3.0

    #!/usr/bin/env python# -*- coding: utf-8 -*-# @Time : 2018/5/27 0027 14:07# @Author : Anthony.Waa# @ ...

  10. SQL学习——小结练习(1)

    到处淘来的SQL题 1. 用一条SQL 语句 查询出每门课都大于80 分的学生姓名 name   kecheng   fenshu 张三     语文       81张三     数学       ...