# 111qqz的小窝

## leetcode 60. Permutation Sequence (求第k个排列)

The set [1,2,3,,<i>n</i>] contains a total of n! unique permutations.

By listing and labeling all of the permutations in order,
We get the following sequence (ie, for n = 3):

1. "123"
2. "132"
3. "213"
4. "231"
5. "312"
6. "321"

Given n and k, return the kth permutation sequence.

Note: Given n will be between 1 and 9 inclusive.

## leetcode 46. Permutations (生成全排列，无重复元素)

Given a collection of distinct numbers, return all possible permutations.

## leetcode 31. Next Permutation (in-place 生成下一个全排列)

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.

If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).

The replacement must be in-place, do not allocate extra memory.

Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.
1,2,31,3,2
3,2,11,2,3
1,1,51,5,1

The following algorithm generates the next permutation lexicographically after a given permutation. It changes the given permutation in-place.

1. Find the largest index k such that a[k] < a[k + 1]. If no such index exists, the permutation is the last permutation.
2. Find the largest index l greater than k such that a[k] < a[l].
3. Swap the value of a[k] with that of a[l].
4. Reverse the sequence from a[k + 1] up to and including the final element a[n].

## hdu 2049 不容易系列之(4)——考新郎 (错排公式，注意精度)

hdu 2049 题目链接

double表示整数也是会丢失精度的！！！

double表示整数也是会丢失精度的！！！

double表示整数也是会丢失精度的！！！

double表示整数也是会丢失精度的！！！

double表示整数也是会丢失精度的！！！

hdu2048 题目链接