Repeatless Numbers[POJ2956]
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 1719 | Accepted: 726 | 
Description
A repeatless number is a positive integer containing no repeated digits. For instance, the first 25 repeatless numbers are
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, …
Given an integer n, your goal is to compute the nth repeatless number.
Input
The input test file will contain multiple test cases, each consisting of a single line containing the integer n, where 1 ≤ n ≤ 1000000. The end-of-file is marked by a test case with n = 0 and should not be processed.
Output
For each input case, the program should print the nth repeatless number on a single line.
Sample Input
25
10000
0
Sample Output
27
26057
Source
#include<stdio.h>
#include<string.h>
int f[];
int T=-;
int s[];
int d[];
int sum=;
void dfs(int dep)
{
int i;
if (dep==)
{
int tmp=d[];
for (i=;i<=;i++) tmp=tmp*+d[i];
T++;
f[T]=tmp;
return;
}
if (T>) return;
for (i=;i<=;i++)
if (s[i]==)
{
d[dep+]=i;
sum+=i;
if (sum) s[i]++;
dfs(dep+);
if (sum) s[i]--;
sum-=i;
}
}
void prepare()
{
memset(s,,sizeof(s));
dfs();
}
int main()
{
prepare();
int N;
while (scanf("%d",&N)!=EOF && N) printf("%d\n",f[N]);
return ;
}
Repeatless Numbers[POJ2956]的更多相关文章
- poj2956 Repeatless Numbers(枚举|BFS)
		题目链接 http://poj.org/problem?id=2956 题意 如果一个数中的每一位都是不同的,那么这个数叫做无重复数,如11是有重复数,12是无重复数.输入正整数n(1<=n&l ... 
- HOJ题目分类
		各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ... 
- Soj题目分类
		-----------------------------最优化问题------------------------------------- ----------------------常规动态规划 ... 
- Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range
		在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ... 
- POJ 2739. Sum of Consecutive Prime Numbers
		Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ... 
- [LeetCode] Add Two Numbers II 两个数字相加之二
		You are given two linked lists representing two non-negative numbers. The most significant digit com ... 
- [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字
		Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ... 
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
		Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ... 
- [LeetCode] Bitwise AND of Numbers Range 数字范围位相与
		Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ... 
随机推荐
- 第14章 使用DHCP动态管理主机地址
			章节简述: DHCP协议服务能够自动化的管理局域网内的主机IP地址,有效的提升IP地址使用率,提高配置效率,减少管理与维护成本. 学习dhcpd服务程序的使用方法并逐条讲解配置参数,完整演示自动化分配 ... 
- C++中的memset()函数  ------------转自:http://www.360doc.com/content/10/1006/18/1704901_58866679.shtml
			memset()函数可以对大内存的分配进行很方便的操作(初始化),所谓“初始化”,当然是指将你定义的变量或申请的空间赋予你所期望的值,例如语句int i=0;就表明定义了一个变量i,并初始化为0:如果 ... 
- Linux下列格式化工具 - column
			[root@localhost ~]# mount/dev/sda2 on / type ext4 (rw)proc on /proc type proc (rw)sysfs on /sys type ... 
- php数组转换js数组操作及json_encode应用
			对于php,个人感觉能够熟练操作数组和字符串,基本上已经是入门了,php本身有很多操作数组和字符串的函数,今天在做一个功能时,需要用Js动态的创建门店信息,这些信息是要从后台添加的,想来想去,通过ph ... 
- 【转】Maven最佳实践:划分模块
			转自:http://juvenshun.iteye.com/blog/305865 “分天下为三十六郡,郡置守,尉,监” —— <史记·秦始皇本纪> 所有用Maven管理的真实的项目都应该 ... 
- Eclipse在已创建的project中导入其他文件
			Eclipse在已创建的project中导入其他文件 前两天被同事问到,如何通过不拷贝源文件的方式,在之前已经创建好的project中直接导入其他目录下的文件, 整理了一下,将目前所知道的eclips ... 
- Google Code Jam 2014 Round 1B Problem B
			二进制数位DP,涉及到数字的按位与操作. 查看官方解题报告 #include <cstdio> #include <cstdlib> #include <cstring& ... 
- iOS 中的第三方库管理工具
			xcode没有android studio中的gradle进行第三方库管理,但是有第三方的库管理工具CocoaPods,https://github.com/CocoaPods/CocoaPods/w ... 
- Linux删除乱码文件
			2015年2月28日 17:11:54 1. ls -i 列出文件的inode号 ??Φ-ͦ?+?-ˬͩ-????-??.doc 2. find folder -inum -delete -de ... 
- codeforces  B. Levko and Permutation  解题报告
			题目链接:http://codeforces.com/problemset/problem/361/B 题目意思:有n个数,这些数的范围是[1,n],并且每个数都是不相同的.你需要构造一个排列,使得这 ... 
