码迷,mamicode.com
首页 > 其他好文 > 详细

五月の诈尸笔记

时间:2016-05-07 20:56:03      阅读:245      评论:0      收藏:0      [点我收藏+]

标签:

最近状态超差。省赛惶恐。

强行插队的后果就是主刀沉迷考研副刀沉迷英语辅助沉迷力学。

趁着马上到来的公费旅游调养一下生息。然而马上要考试了。

 

5.7

xdu 1158 Orz Fatality

不是很懂数学。

技术分享
 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 typedef long long LL;
 5 const LL mod = 1e9 + 7;
 6 const int maxn = 1e7 + 10;
 7 LL fac[maxn];
 8 
 9 LL qpow(LL a, int b)
10 {
11     LL ret = 1LL;
12     while(b)
13     {
14         if(b & 1) ret = ret * a % mod;
15         a = a * a % mod;
16         b >>= 1;
17     }
18     return ret;
19 }
20 
21 LL inv(LL x)
22 {
23     return qpow(x, mod - 2);
24 }
25 
26 int main(void)
27 {
28     fac[0] = 1LL;
29     for(int i = 1; i < maxn; i++) fac[i] = fac[i-1] * i % mod;
30     LL x, y, k;
31     while(~scanf("%lld %lld %lld", &x, &y, &k))
32     {
33         if(k > y) puts("0");
34         else if(k == y) puts("1");
35         else
36         {
37             if(x + y >= maxn || x + k >= maxn) while(1);
38             LL ans = fac[x+y] * inv(fac[x+k]) % mod * inv(fac[y-k]) % mod;
39             printf("%lld\n", ans);
40         }
41     }
42     return 0;
43 }
Aguin

 

五月の诈尸笔记

标签:

原文地址:http://www.cnblogs.com/Aguin/p/5469128.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!