nyoj 光棍节的快乐

http://acm.nyist.net/JudgeOnline/problem.php?pid=451

View Code
 1 #include<stdio.h>
 2 long long  a[22],b[22];
 3 void cuo_pai()
 4 {
 5     a[1]=0;
 6     a[2]=1;
 7     for(int i=3;i<=22;i++)
 8     a[i]=(i-1)*(a[i-1]+a[i-2]);
 9 }
10 int main()
11 {
12     long long aa,b;
13     cuo_pai();
14     while(~scanf("%lld%lld",&aa,&b))
15     {
16     //    printf("%d\n",a[b]);
17         long long temp=b;
18         long long ccc=b;
19         long long sum=1;
20         while(b)
21         {
22             sum*=aa;
23             aa--;
24             b--;
25         }
26         while(temp)
27         {
28             sum/=temp;
29             temp--;
30         }
31         printf("%lld\n",sum*a[ccc]);
32     }
33 }

 

posted on 2012-08-24 17:21  仁者无敌8勇者无惧  阅读(127)  评论(0编辑  收藏  举报

导航