Glenn's ACM code

什麼事都盡全力去做吧!!

2009年2月10日 星期二

Q530: Binomial Showdown

// Run time: 0.000
#include <stdio.h>
void combination(int N, int M);
int main()
{
int N, M;
while (true)
{
scanf("%d%d", &N, &M);
if (!N && !M) break;

if (M > N/2)
M = N - M;

combination(N, M);
}
return 0;
}

void combination(int N, int M)
{
int i;
double prod = 1;
for ( i = 0; i < M; i++)
prod *= double(N--)/double(i+1);

printf("%.0lf\n", prod);
}
張貼者: Glenn Chen 於 上午8:34
標籤: ACM

沒有留言:

張貼留言

較新的文章 較舊的文章 首頁
訂閱: 張貼留言 (Atom)

Programming

  • 練習 (1)
  • ACM (65)

網誌存檔

  • ▼  2009 (66)
    • ►  05/03 - 05/10 (1)
    • ►  04/26 - 05/03 (1)
    • ►  03/29 - 04/05 (1)
    • ►  03/22 - 03/29 (1)
    • ►  03/08 - 03/15 (9)
    • ►  03/01 - 03/08 (6)
    • ►  02/22 - 03/01 (16)
    • ►  02/15 - 02/22 (7)
    • ▼  02/08 - 02/15 (19)
      • Q343: What Base Is This ?
      • Q679: Dropping Balls
      • Q686: Goldbach's Conjecture(II)
      • Q661: Blowing Fuses
      • Q612: DNA Sorting
      • Q587: There's treasure everywhere!
      • Q576: Hiaku Review
      • Q573: The Snail
      • Q568: Just the Facts
      • Q555: Bridge Hands
      • Q543: Goldbach's Conjecture
      • Q530: Binomial Showdown
      • Q516: Prime Land
      • Q498: Polly the Polynomial
      • Q492: Pig-Latin
      • Q490: Rotating Sentences
      • Q484:The Department of Redundancy Department
      • Q483: Word Scramble
      • Q482: Permutation Arrays
    • ►  02/01 - 02/08 (5)

連結

  • Algorithm Design Paradigms
  • 良葛格學習筆記
  • C++ Algorithms [C++ Reference]
  • A Tutorial on Dynamic Programming
  • UVa Online Judge
  • Lucky 貓的 ACM 園地
  • 美麗 C 世界
  • UVA toolkit
頂尖企業主題. 技術提供:Blogger.