20170402"尚学堂杯"哈尔滨理工大学第七届程序设计竞赛ABCDFG题解

第一次参加个人赛

想着自己太辣稽肯定不能拿最佳新人

最后A了3题

实在是太辣稽了

A题 组合数取模 因为以为是很难的数学题就没做 我好智障...

B题 思维题 一开始太不谨慎了wa了几发...

C题 走台阶问题 因为没意识到数组初始赋值错了 一直错到比赛结束都不知道怎么回事 我好智障...

D题 简单Floyd 比赛时没读懂题意 赛后知道是Floyd实在是好气啊(捂脸痛哭)

F题 简单字符串模拟

G题 二进制 我竟然水过了

_______________________________________________________

Astonishing Combinatorial Number
Time Limit: 8000 MS Memory Limit: 512000 K
Total Submit: 56(11 users) Total Accepted: 14(9 users) Rating: Special Judge: No
Description

The combinatorial number CmnCnm in combinatorics, where it gives the number of the ways, disregarding order,

the m objects can be chosen from among n objects; more formally, the number of m-element subsets (or m-combinations)

of an n-element set.

Now, there's a simple problem about this number:

For three given number n, m and k, how many pairs of (i, j) will make the equation A.a be true. (0 <= i <= n, 0 <= j <= min(i, m))

Equation A.1:

Cjimodk=0Cijmodk=0

Input

There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases.

For each test case:
The first line contains two integers t(1<=t<=10^4) and k(1<=k<=30).
Each of the next t lines contains two integers n(1<=n<=2000) and m(1<=m<=2000) .


Output
Each test case should contain t lines. Each line has an integer indicate the answer of the problem.

Sample Input
2
1 2
3 3
2 5
4 5
6 7
Sample Output

1

0

7

Hint
In first test case, onlyC12=2C21=2 is multiple of 2.
Source
"尚学堂杯"哈尔滨理工大学第七届程序设计竞赛
题意:给出n m k 求Cij mod k的方案数


思路:首先预处理(打表),然后统计方案数。

1

1  1

1  2  1

1  3  3  1

...................

#include
  
  
   
   
#include
   
   
    
    
#include
    
    
     
     
using namespace std;
int c[2005][2005];
int main()
{
	int T;
	int t,k;
	while(~scanf("%d",&T))
		while(T--)
		{
			scanf("%d%d",&t,&k);
			memset(c,0,sizeof(c));
			c[0][0]=1%k;
			for(int i=1;i<2005;i++)
			{
				c[i][0]=1%k;
				c[i][i]=1%k;
			}

			for(int i=1;i<2005;i++)
				for(int j=1;j
     
     
    
    
   
   
  
  


Blind Father
Time Limit: 1000 MS Memory Limit: 512000 K
Total Submit: 131(57 users) Total Accepted: 66(54 users) Rating: Special Judge: No
Description
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值