RPG's Wrong row
Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 8489 Accepted Submission (s): 3465
Problem description this summer holiday training team The first composition girls team, including a team called RPG, but as one of the training team members of the wild camel unexpectedly do not know RPG three person specifically who. RPG gave him the chance to let him guess, the first guess: R is the princess, p is the grass, G is the Moon hare; the second guess: R is grass, p is the Moon hare, G is the princess; Third guess: R is grass, p is princess, G is moon Hare; The poor wild camel finally divided the RPG for the sixth time. Because of the drive of the RPG, more and more women to do ACM, our wild camel want to know them, but now there are n many people, he has to guess the number of times, in order not to embarrass the wild camel, girls only ask him to correct half or above even if the clearance, how many groups of answers can make him smooth clearance.
Input data has multiple case, each case includes an n, representing a few girls, (n<=25), n = 0 input end.
Sample Input
120
Sample Output
11
Authorrabbit
SOURCERPG Practice CompetitionI
met three wrong platoon!!!! today. The difficulty increases obviously, but original aim!
attention this time is half right or more than half to calculate clearance!! From the opposite side, because asked is the number of methods, when the right half of the time, the half and the name of one by one corresponding, the remaining half of the name and the wrong platoon, the same answer to n/2+1 personal, then the rest of the wrong row ... Add in turn. Notice that the termination condition is when the right n-1 the person left when the wrong row of 0, so must be correct, but the termination of the conditions in line with test instructions, finally added sum+1 Ah!!
#include <iostream> #include <algorithm>using namespace Std;int main () {_int64 Ls[30]={0,0,1};_int64 gq[30] ={1,1,2};for (int i=3;i<26;i++) {ls[i]= (i-1) * (Ls[i-1]+ls[i-2]); gq[i]=gq[i-1]*i;} int N;while (cin>>n,n) {_int64 sum=0;if (n==1| | n==2| | n==3) {cout<<1<<endl; Continue;} for (int k=n/2;k>1;k--) sum+=gq[n]/(Gq[k]*gq[n-k]) * (Ls[k]);p rintf ("%i64d\n", sum+1);} return 0;}
Hangzhou Electric HDU ACM 2068 RPG's Wrong row