/*
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. Mac OSX Yosemite 10.10 brew 错误:mktemp: mkdtemp failed on /tmp/git-LIPo: No such file or directory

    这个问题困扰了我非常久非常久.使得我不得不花一点时间来说一下解决方法. 事情是这种:前两天兴高採烈的更新了一下宝贝mac到10.10. 一切看起来都那么美好,可是. .当我又一次安装magento的时 ...

  2. MongodDB用GridFS方式存取文件

    在实现GridFS方式前我先讲讲它的原理,为什么可以存大文件.驱动首先会在当前数据库创建两个集合:"fs.files"和"fs.chunks"集合,前者记录了文 ...

  3. HTTP协议头了解

    Cache-Control:max-age =0 Cache-Control no-cache — 强制每次请求直接发送给源服务器,而不经过本地缓存版本的校验.这对于需要确认认证应用很有用(可以和pu ...

  4. c6----函数的声明和实现

    // // main.c // 函数的声明和定义 // // Created by xiaomage on 15/6/7. // Copyright (c) 2015年 xiaomage. All r ...

  5. FC 网络

    通常情况下,SAN系统中服务器与存储介质通过一种特殊的网络相连,这种网络就是FC 网络. FC 网络是一种新发展的与传统的TCP/IP网络并列的一种高速网络.它有自己的地址分配和网络管理的体系. FC ...

  6. ROS-单目摄像头标定

    前言:由于摄像图内部与外部的原因,生成的图像往往会发生畸变,为了避免数据源造成的误差,需要针对摄像头的参数进行标定. ros官方提供了camera_calibration软件包进行摄像头标定. 一.安 ...

  7. Centos7 minimal 系列之Nginx负载均衡搭建(四)

    一.Nginx搭建请参考我的上篇文章 http://www.cnblogs.com/WJ--NET/p/8143899.html 二.在IIS上搭建2个网站 三.配置nginx 虚拟机和主机网络互通请 ...

  8. CLR - 设计类型

    前言 好记性不如烂“笔头”系列... 目录 类型基础 基元类型.引用类型和值类型 类型与成员 常量与字段 方法 类型基础 “运行时”要求每个类型最终都从System.Object 类型派生. 由于所有 ...

  9. DDD中Dto领域驱动设计概述,摘自《NET企业级应用架构设计》

  10. 洛谷 p2618 数字工程 记忆化搜索_ 线性筛

    我们在线筛的同时处理出每个数的所有质因子,记忆化搜索的时候直接枚举质因子即可. 时间复杂度为 O(nlogn)O(nlogn)O(nlogn) Code: #include<cstdio> ...