SDUT2883 hearthstone//stirling

Source: Internet
Author: User

Fifth session of the provincial race: Hearthstone

Combinatorial mathematics.

n Races, M tables (n>=m). Each race is a table, and each table is used at least once.

The idea behind the question has been how to fill the M table with n positions.

is actually the Tao Stirling number model, the direct set formula M!*{n m}

#include <stdio.h>#include<string.h>#defineL 1000000007intMain () {intn,m; Long Longa[101];  while(SCANF ("%d%d", &n,&m)! =EOF) {a[0]=0;  for(intI=1; i<=n;i++) A[i]=1;  for(intI=3; i<=n;i++)             for(intj=i-1;j>0; j--) A[j]= (j*a[j]%l+a[j-1])%m;  for(intI=1; i<=m;i++) A[m]= ((a[m]%l) *i)%L; printf ("%lld\n", A[m]); }    return 1;}
View Code

Not at first, then the array is opened to a long long on the line >_<

SDUT2883 hearthstone//stirling

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.