设计购物网站咋做,国外搜索网站建设,wordpress 使用教程,wordpress备份content题目链接 这个题目的组合解法#xff0c;太巧妙了。长度为n的方案数总和为C(26,n)#xff0c;我竟没有发现。。然后长度和字符串相等的时候的情况#xff0c;第一位默认#xff0c;以后默认为前一位1#xff0c;这样才能保证递增特性。 网上还有DP解法#xff0c;智商拙计…题目链接 这个题目的组合解法太巧妙了。长度为n的方案数总和为C(26,n)我竟没有发现。。然后长度和字符串相等的时候的情况第一位默认以后默认为前一位1这样才能保证递增特性。 网上还有DP解法智商拙计啊。。。 1 #include iostream2 #include cstdio3 #include cstring4 using namespace std;5 int c[27][27];6 int main()7 {8 int i,j,k,len;9 long long ans 0;
10 char str[101];
11 for(i 0;i 26;i )
12 c[i][0] 1;
13 for(i 1;i 26;i )
14 {
15 for(j 1;j i;j )
16 c[i][j] c[i-1][j-1] c[i-1][j];
17 }
18 scanf(%s,str);
19 len strlen(str);
20 for(i 0;i len-1;i )
21 {
22 if(str[i] str[i1])
23 {
24 printf(0\n);
25 return 0;
26 }
27 }
28 for(i 1;i len-1; i)
29 {
30 ans c[26][i];
31 }
32 for(i 0;i len; i)
33 {
34 if(i 0)
35 j a;
36 else
37 j str[i-1] 1;
38 for(;j str[i];j )
39 {
40 ans c[z-j][len-i-1];
41 }
42 }
43 printf(%lld\n,ans1);
44 return 0;
45 } 转载于:https://www.cnblogs.com/naix-x/archive/2013/01/22/2871491.html