USACO runaround
/*
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的更多相关文章
- USACO Runaround Numbers 模拟
根据题意的 Runaround 规则去找比当前数大的最近的一个 Runaround数字 模拟题~ Source code: /* ID: wushuai2 PROG: runround LANG: C ...
- USACO Runaround Numbers
题目大意:问最近的比n大的循环数是多少 思路:第n遍暴力大法好 /*{ ID:a4298442 PROB:runround LANG:C++ } */ #include<iostream> ...
- USACO 2.2 Runaround Numbers
Runaround Numbers Runaround numbers are integers with unique digits, none of which is zero (e.g., 81 ...
- 【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
P1467 循环数 Runaround Numbers 89通过 233提交 题目提供者该用户不存在 标签USACO 难度普及/提高- 提交 讨论 题解 最新讨论 暂时没有讨论 题目描述 循环数是 ...
- Luogu USACO Training 刷水记录
开个坑记录一下刷USACO的Training的记录 可能会随时弃坑 只有代码和做法简述 可能没有做法简述 [USACO1.1]你的飞碟在这儿Your Ride Is He… 模拟,细节已忘 #incl ...
随机推荐
- C++ 浅析 STL 中的 list 容器
list - 擅长插入删除的链表 链表对于数组来说就是相反的存在. 数组本身是没有动态增长能力的(程序中也必须又一次开辟内存来实现), 而链表强悍的就是动态增长和删除的能力. 但对于数组强悍的随机訪问 ...
- 英语发音规则---F字母
英语发音规则---F字母 一.总结 一句话总结: 1.F/FF发[f]音? fly [flaɪ] vi. 飞 fine [faɪn] adj. 好的 float [fləʊt] vt. 使漂浮 fra ...
- linux HBA 卡驱动安装
系统环境操作系统 : RHEL5.0设备 DL580G5 HBA 卡:Qlogic 2343连接存储: EVA8100---------------------------------------- ...
- 12.Matlab神经网络工具箱
概述: 1 人工神经网络介绍 2 人工神经元 3 MATLAB神经网络工具箱 4 感知器神经网络 5 感知器神经网络 5.1 设计实例分析 clear all; close all; P=[ ; ]; ...
- Ubuntu14.04下Mongodb的Java API编程实例(手动项目或者maven项目)
不多说,直接上干货! 若大家,不会安装的话,则请移步,随便挑选一种. Ubuntu14.04下Mongodb(在线安装方式|apt-get)安装部署步骤(图文详解)(博主推荐) Ubuntu14.04 ...
- HD-ACM算法专攻系列(20)——七夕节
问题描述: AC源码: /**/ #include"iostream" #include"cmath" using namespace std; int mai ...
- Route学习笔记
前言 UrlRoutingModule.class:这块的代码关联了上一篇中路由部分的一个详细说明 一:Route的讲解 1. 路由模板匹配 添加路由: MapRoute 剔除的路由:IgnoreRo ...
- WebApi不支持跨域访问
- Eclipse插件Lambok,实现自动生成Java代码
1.下载Lombok.jar http://projectlombok.googlecode.com/files/lombok.jar 2.运行Lombok.jar: java -jar D:\00 ...
- ES6 | ES6新语法 在编码实践中的应用
本章探讨如何将 ES6 的新语法,运用到编码实践之中,与传统的 JavaScript 语法结合在一起,写出合理的.易于阅读和维护的代码. 多家公司和组织已经公开了它们的风格规范,本文的内容主要参考了 ...