Problem Description There are many students in PHT School. One day, the headmaster whose name is PigHeader wanted all students stand in a line. He prescribed that girl can not be in single. In other words, either no girl in the queue or more than one…
Children’s Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 17918    Accepted Submission(s): 5976 Problem Description There are many students in PHT School. One day, the headmaster whose na…
递推,最近发现自己做递推的题总是没有思路.下周多练习.对于f(n)可以在第n个位置为男生,此时共有f(n-1)种情况:若在第n个位置为女生,因此第n-1个位置也必须为女生.此时有两种情况,一种情况是在f(n-2)后直接添加FF,另一种情况是在MF后添加FF将本来错误的串改为正确的,这种情况数量为f(n-4)(前n-4排列满足要求).因此,f(n) = f(n-1) + f(n-2) + f(n-4).题目数据超过64位,大数AC. #include <stdio.h> #include <…
版权声明:来自: 码代码的猿猿的AC之路 http://blog.csdn.net/ck_boss https://blog.csdn.net/u012797220/article/details/35860567 JAVA大数.... Children's Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10390    …
这道题是排序问题,可以用递归方法解决. 计算F(n): 一:当最后一个是男孩M时候,前面n-1个随便排出来,只要符合规则就可以,即是F(n-1): 二:当最后一个是女孩F时候,第n-1个肯定是女孩F,这时候又有两种情况: 1)前面n-2个可以按n-2个的时候的规则来,完全可以,即是F(n-2): 2)但是即使前面n-2个人不是合法的队列,加上两个女生也有可能是合法的.当第n-2是女孩而n-3是男孩的情况,可能合法,情况总数为F(n-4); 综上所述:总数F(n)=F(n-1)+F(n-2)+F(…
Problem Description 给你一个高为n ,宽为m列的网格,计算出这个网格中有多少个矩形,下图为高为2,宽为4的网格. Input 第一行输入一个t, 表示有t组数据,然后每行输入n,m,分别表示网格的高和宽 ( n < 100 , m < 100). Output 每行输出网格中有多少个矩形. Sample Input 2 1 2 2 4 Sample Output 3 30 此方格其实就是求其中所有格子数,如果按宽度来算的话,1,2,3,-m,种情况,对每一种情况,有(1+2…
Problem Description Consecutive sum come again. Are you ready? Go ~~ 1 = 0 + 1 2+3+4 = 1 + 8 5+6+7+8+9 = 8 + 27 - You can see the consecutive sum can be representing like that. The nth line will have 2*n+1 consecutive numbers on the left, the first n…
Children’s Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12101 Accepted Submission(s): 3953 Problem Description There are many students in PHT School. One day, the headmaster whose name is…
Children’s Queue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8835    Accepted Submission(s): 2813 Problem Description There are many students in PHT School. One day, the headmaster whose nam…
Children's Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 959 Accepted Submission(s): 534 Problem Description There are many students in PHT School. One day, the headmaster whose name is Pi…