南邮 OJ 1682 非递减字符串问题

非递减字符串问题

时间限制(普通/Java) :  1000 MS/ 3000 MS          运行内存限制 : 81920 KByte
总提交 : 179            测试通过 : 29 

比赛描述

在非递减字符串中,

从左到右的字符依次按

ASC

码非递减排列,

例如

abcd

其他

4

个字符组成的非递减字符串还有

aaaa

aabb

aaab

abcc

等。现在假设字

符串由

a

b

c

d

e

f

g

h

i

j

10

个字符组成。请你编程确定特定长

度的非递减字符串的数目。

在非递减字符串中,

从左到右的字符依次按

ASC

码非递减排列,

例如

abcd

其他

4

个字符组成的非递减字符串还有

aaaa

aabb

aaab

abcc

等。现在假设字

符串由

a

b

c

d

e

f

g

h

i

j

10

个字符组成。请你编程确定特定长

度的非递减字符串的数目。

在非递减字符串中,从左到右的字符依次按ASC码非递减排列,例如abcd,其他4个字符组成的非递减字符串还有aaaa,aabb,aaab,abcc等。现在假设字符串由a、b、c、d、e、f、g、h、i、j等10个字符组成。请你编程确定特定长度的非递减字符串的数目。



输入

输入包括多个测试用例,首先给出测试用例数P(1≤P≤1000),接着给出P个测试用例。每一个测试用例包括一行,给出以空格分隔的两个整数,第1个整数表示测试用例序号,第二整数表示字符串的长度N(1≤N≤64)。

输出

输出包括多行,对于每个测试用例输出一行,输出以空格分隔的两个整数,第1个整数为测试用例序号,第二整数给出长度为N的非递减字符串数目。

样例输入

2
1 4
2 3

样例输出

1 715
2 220

题目来源

NUPT





#include<iostream>
#include<string>
using namespace std;

int main(){
	string s[100]={"10","55","220","715","2002","5005","11440","24310","48620","92378","167960","293930","497420","817190","1307504","2042975","3124550","4686825","6906900","10015005","14307150","20160075","28048800","38567100","52451256","70607460","94143280","124403620","163011640","211915132","273438880","350343565","445891810","563921995","708930508","886163135","1101716330","1362649145","1677106640","2054455634","2505433700","3042312350","3679075400","4431613550","5317936260","6358402050","7575968400","8996462475","10648873950","12565671261","14783142660","17341763505","20286591270","23667689815","27540584512","31966749880","37014131440","42757703560","49280065120","56672074888","65033528560","74473879480","85113005120","97082021465","110524147514","125595622175","142466675900","161322559475","182364632450","205811513765","231900297200","260887834350","293052087900","328693558050","368136785016","411731930610","459856441980","512916800670","571350360240","635627275767","706252528630","783768050065","868754947060","961835834245","1063677275518","1174992339235","1296543270880","1429144287220","1573664496040","1731030945644","1902231808400","2088319702700","2290415157800","2509710226100","2747472247520","3005047770725","3283866636050","3585446225075","3911395881900","4263421511271"};
	int P, i, N;
	cin>>P;
	while(P--){
		cin>>i>>N;
		cout<<i<<' '<<s[N-1]<<endl;
	}
}




/*
#include<iostream>
#include<fstream>
using namespace std;

int main(){
	long long a[10]={1,1,1,1,1,1,1,1,1,1}, N=100, i, j;
	ofstream f("output.txt");
	//n=1,线段长度;n=2,三角形面积;n=3三棱锥体积,n>3多维立体体积,可画图帮组理解
	for(i=1; i<=N; i++){
		for(j=1; j<10; j++){
			a[j] += a[j-1];
		}
		f<<"\""<<a[9]<<"\",";
	}
}*/



你可能感兴趣的:(ACM,南邮OJ,非递减字符串问题)