就是经典约瑟夫环问题的裸题 我一开始一直没理解这个递推是怎么来的,后来终于理解了 假设问题是从n个人编号分别为0...n-1,取第k个, 则第k个人编号为k-1的淘汰,剩下的编号为  0,1,2,3...k-2,k,k+1,k+2... 此时因为从刚刚淘汰那个人的下一个开始数起,因此重新编号 把k号设置为0,则 k    0 k+1 1 ... 0 n-k 1 n-k+1 假设已经求得了n-1个人情况下的最终胜利者保存在f[n-1]中,则毫无疑问,该胜利者还原到原来的真正编号即为 (f[n-1]…
以数组的方法: public static void main(String[] args) {        final int n = 10;          final int k = 1;          final int m = 3;          start(n, k, m);   }    public static void start(int n, int k, int m){          //生产数组          int[] arrays = new i…
http://poj.org/problem?id=3597 题目大意:把一个正多边形分成数个三角形或者四边形,问有多少种方案. 思路:http://www.cnblogs.com/Ritchie/p/5939844.html 然后说一下这个式子的转换...md数学果然太差了,花了我好久 U(n)=∑T(i)*T(n-i+1);(2<=i<=n-1)T(n)=U(n)+∑T(i)*U(n-i+1);(2<=i<=n-2) 因为U(n)=∑T(j)*T(n-j+1);(2<=j…
1045: [HAOI2008] 糖果传递 Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2975 Solved: 1327 [Submit][Status][Discuss] Description 有n个小朋友坐成一圈,每人有ai个糖果.每人只能给左右两人传递糖果.每人每次传递一个糖果代价为1. Input 小朋友个数n 下面n行 ai Output 求使所有人获得均等糖果的最小代价. Sample Input 4 1 2 5 4 Sampl…
将K个不超过N的非负整数加起来,使它们的和为N,一共有多少种方法. 设d(i, j)表示j个不超过i的非负整数之和为i的方法数. d(i, j) = sum{ d(k, j-1) | 0 ≤ k ≤ i },可以理解为前j-1个数之和为i-k,最后一个数为k 还有一种更快的递推办法,把这个问题转化为将N个小球放到K个盒子中的方法数,盒子可以为空. 就等价于求x1 + x2 +...+ xK = N的非负整数解的个数,根据组合数学的知识容易算出结果为C(N+K-1, K-1). 所以也可以这样递推…
I Think I Need a Houseboat Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9530    Accepted Submission(s): 2733 Problem Description Fred Mapper is considering purchasing some land in Louisiana…
Description Edward is the headmaster of Marjar University. He is enthusiastic about chess and often plays chess with his friends. What's more, he bought a large decorative chessboard with N rows and M columns. Every day after work, Edward will place…
时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 大家对斐波那契数列想必都很熟悉: a0 = 1, a1 = 1, ai = ai-1 + ai-2,(i > 1). 现在考虑如下生成的斐波那契数列: a0 = 1, ai = aj + ak, i > 0, j, k从[0, i-1]的整数中随机选出(j和k独立). 现在给定n,要求求出E(an),即各种可能的a数列中an的期望值. 输入 一行一个整数n,表示第n项.(1<=n<=500) 输出 一行一个…
Description Golden ratio base (GRB) is a non-integer positional numeral system that uses the golden ratio (the irrational number (1+√5)/2 ≍ 1.61803399 symbolized by the Greek letter φ) as its base. It is sometimes referred to as base-φ, golden mean b…
Description Prof. Tigris is the head of an archaeological team who is currently in charge of an excavation in a site of ancient relics.        This site contains relics of a village where civilization once flourished. One night, examining a writing r…