• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            coreBugZJ

            此 blog 已棄。

            Vote, FZU 2011年3月月賽之 F, FZU 2015

            Problem 2015 Vote

            Time Limit: 1000 mSec    Memory Limit : 32768 KB

            Problem Description

            Here are n Candidates in one election. Every Candidate could vote any one (of course himself/herself). In this election, the one who gets more than half of n become the winner! However, sometimes no winner could be determined (No one gets more than half of n votes)!

            Now you are given the number of Candidates and the final winner m, here if m is equal to -1, then it means that no one wins, otherwise m is the index of the Candidate. (The index of Candidates is 0, 1, 2, … n – 1 respectively) Abcdxyzk wants to know the number of possible ways of the final result if the winner if m. (m = -1 for no winner of course) However, the answer maybe large, so abcdxyzk just want the remainder of the answer after divided by 1000000007.

            Input

            There are several test cases.

            For each case, only two integers n and m in a single line indicates n Candidates and the final winner m. (1 <= n <= 100, -1 <= m < n)

            Output

            For each test case, output the number of possible ways of the final election!

            Sample Input

            2 1
            3 -1
            4 1

            Sample Output

            1
            1
            4

            Hint

            In case 1, only one possible ways of the final result because both 0 and 1 vote to 1.

            In case 2, only one possible ways of the final result because all of 0, 1, and 2 get one vote.

            In case 3, there are 4 possible ways of final result:

            (1) 0: 1 (vote(s)) 1: 3 (vote(s)) 2: 0 (vote(s)) 3: 0 (vote(s))

            (2) 0: 0 (vote(s)) 1: 3 (vote(s)) 2: 1 (vote(s)) 3: 0 (vote(s))

            (3) 0: 0 (vote(s)) 1: 3 (vote(s)) 2: 0 (vote(s)) 3: 1 (vote(s))

            (4) 0: 0 (vote(s)) 1: 4 (vote(s)) 2: 0 (vote(s)) 3: 0 (vote(s))

            Source

            FOJ有獎月賽-2011年03月


            組合數。

            我的代碼:
             1 #include <stdio.h>
             2 
             3 typedef  long  long  Lint;
             4 
             5 #define  L  203
             6 #define  MOD  1000000007
             7 
             8 int c[ L ][ L ];
             9 
            10 int main() {
            11         int n, m, i, j, ans;
            12         for ( i = 0; i < L; ++i ) {
            13                 c[ i ][ 0 ] = c[ i ][ i ] = 1;
            14                 for ( j = 1; j < i; ++j ) {
            15                         c[ i ][ j ] = ( c[ i - 1 ][ j - 1 ] + c[ i - 1 ][ j ] ) % MOD;
            16                 }
            17         }
            18         while ( scanf( "%d%d"&n, &m ) == 2 ) {
            19                 if ( m < 0 ) {
            20                         ans = ( c[n+n-1][n] + (Lint)(MOD-c[(n-1)+(n-n/2-1)][n-1]) * n ) % MOD;
            21                 }
            22                 else {
            23                         ans = c[ (n-1+ (n-n/2-1) ][ n-1 ];
            24                 }
            25                 printf( "%d\n", ans );
            26         }
            27         return 0;
            28 }
            29 

            posted on 2011-03-23 22:46 coreBugZJ 閱讀(1476) 評論(0)  編輯 收藏 引用 所屬分類: ACM

            久久91精品国产91| 麻豆av久久av盛宴av| 91久久香蕉国产熟女线看| 国产69精品久久久久99尤物| 无码国内精品久久人妻麻豆按摩| 伊人色综合久久天天人守人婷| 久久亚洲精精品中文字幕| 久久强奷乱码老熟女| 中文字幕久久波多野结衣av| 国产精品伦理久久久久久| 久久亚洲国产成人精品性色| 日韩电影久久久被窝网| 热99re久久国超精品首页| 蜜臀av性久久久久蜜臀aⅴ| 久久久久这里只有精品 | 97精品国产97久久久久久免费 | 国产精品久久久久9999| 免费精品久久天干天干| 久久久久亚洲AV无码专区网站| 久久精品国产99久久无毒不卡| 中文字幕无码av激情不卡久久| 丁香久久婷婷国产午夜视频| 狠色狠色狠狠色综合久久| 天天躁日日躁狠狠久久| 97久久婷婷五月综合色d啪蜜芽 | 午夜精品久久影院蜜桃| 国产精品美女久久久久AV福利| 69久久夜色精品国产69| 精品国产VA久久久久久久冰| 久久99精品国产麻豆| 久久精品aⅴ无码中文字字幕重口 久久精品a亚洲国产v高清不卡 | 久久精品国产亚洲AV蜜臀色欲| 亚洲AⅤ优女AV综合久久久| 日本欧美久久久久免费播放网 | 国产综合免费精品久久久| 久久99久久99小草精品免视看| 久久综合精品国产二区无码| 久久久久久夜精品精品免费啦| 欧美黑人又粗又大久久久| 99久久超碰中文字幕伊人| 久久久久免费精品国产|