比赛排名(猎豹笔试编程题)

比赛排名
程序运行时间限制:1秒


问题描述:


N个同学参加一场比赛,比赛结果可能出现并列排名,问最终有多少种可能的不同排名结果。举例说明:假设有3个同学A, B和C参加比赛,则最终的排名结果:


可能是:第一名:B,第二名:C,第三名:A
也可能是:第一名:A和B并列,第二名C;
所有这些可能的不同排名结果共有13种。


输入描述:
第一行输入一个m表示有m组测试数据
以下m行,每行输入一个整数N,表示有N个同学参加比赛,1<=N<=100


输出描述:
输出对于N个同学,不同的排名结果数模10000(即取结果后4位),每个输出占一行


输入样例:
2
1
3


输出样例:
1

13


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#define MAXN 1000  
#define offset 10000  
#define eps 1e-11  
#define PI acos(-1.0)//3.14159265358979323846  
#define exp 2.718281828
#define mod 1000000007
using namespace std;
typedef long long LL;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

//f[i][j]为i个人分为j组 
int f[101][101];
int main(int argc, char** argv) {
	
	for(int i = 0;i<101;i++){
		for(int j = 0;j<101;j++){
			if(j < i || j<1){
				f[i][j] = 0;
			}
			
			if(j == 1 && j<=i){
				f[i][j] = 1;
			}
			if(j > 1 && j<=i){
				f[i][j] = (f[i-1][j]+f[i-1][j-1])*j;
			}
			f[i][j] %= 10000;
		}
	}
	int g;
	scanf("%d",&g);
	while(g--){
		int n;
		scanf("%d",&n);
		int sum = 0;
		for(int i = 1;i<=n;i++){
			sum += f[n][i];
			sum %= 10000;
		}
		printf("%d\n",sum);
	}
	return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值