UVA - 10497 Sweet Child Makes Trouble
来源:互联网 发布:紫格尼克效应 知乎 编辑:程序博客网 时间:2024/06/01 07:48
Children are always sweet but they can sometimesmake you feel bitter. In this problem, you will see how Tintin, a five year’sold boy, creates trouble for his parents. Tintin is a joyful boy and is alwaysbusy in doing something. But what he does is not always pleasant for hisparents. He likes most to play with household things like his father’swristwatch or his mother’s comb. After his playing he places it in some otherplace. Tintin is very intelligent and a boy with a very sharp memory. To makethings worse for his parents, he never returns the things he has taken forplaying to their original places.
Think about a morning when Tintin has managed to‘steal’ three household objects. Now, in how many ways he can place thosethings such that nothing is placed in their original place. Tintin does notlike to give his parents that much trouble. So, he does not leave anything in acompletely new place; he merely permutes the objects.
Input
There will be several test cases. Each will havea positive integer less than or equal to 800 indicating the number of thingsTintin has taken for playing. Each integer will be in a line by itself. The inputis terminated by a –1 (minus one) in a single line, which should not beprocessed.
Output
For each test case print an integer indicating inhow many ways Tintin can rearrange the things he has taken.
Sample Input
2
3
4
-1
SampleOutput
1
2
9题意:放回不同位置的方案数思路:简单的错排问题,高精度处理import java.math.BigInteger;import java.util.Scanner;public class Main {public static void main(String[] args) {final int maxn = 805;BigInteger f[] = new BigInteger[maxn];f[1] = BigInteger.ZERO;f[2] = BigInteger.ONE;for (int i = 3; i < maxn; i++)f[i] = (f[i-2].add(f[i-1])).multiply(BigInteger.valueOf(i-1));Scanner in = new Scanner(System.in);int n;while (true) {n = in.nextInt();if (n == -1)break;System.out.println(f[n]);}}}
- UVA 10497 Sweet Child Makes Trouble
- UVA - 10497 Sweet Child Makes Trouble
- UVA - 10497 Sweet Child Makes Trouble
- UVA 10497 - Sweet Child Makes Trouble(DP+高精度)
- uva 10497 - Sweet Child Makes Trouble(dp+高精度)
- Uva 10497 - Sweet Child Makes Trouble 解题报告(递推+大数)
- Sweet Child Makes Trouble 错排
- (组合数学3.3.2.2)UVA 10497 - Sweet Child Makes Trouble(特殊的排列问题——错排方案数)
- UVA10497---Sweet Child Makes Trouble(dp+java大数计算)
- poj 1680 Fork() Makes Trouble
- SWEET
- Sweet!!!
- UVa 10969 Sweet Dream 继续圆盘问题
- uva 10969 - Sweet Dream(几何)
- UVa 10819 - Trouble of 13-Dots
- UVa 10286 - Trouble with a Pentagon
- 【UVa】10819 - Trouble of 13-Dots
- UVA, 10286 Trouble with a Pentagon
- 工作,到底意味着什么
- android中用线程更新UI,报错only the original thread that created a view hierarchy can touch its views
- 深入理解java虚拟机(二)HotSpot Java对象创建,内存布局以及访问方式
- 常见字符编码
- Linux 密码文件详解
- UVA - 10497 Sweet Child Makes Trouble
- Python中super关键字的作用
- POJ 3691 DNA repair 基于AC自动机的DP
- 带通配符的数
- LeetCode-Remove Duplicates from Sorted Array
- Python之美[从菜鸟到高手]--NotImplemented小析
- Codeforces Round #261 (Div. 2)
- 2015年华为提前招聘机试题--查找完数
- UVA - 297 Quadtrees