hdu4055 Number String】的更多相关文章

Number String Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1027 Accepted Submission(s): 448 Problem Description The signature of a permutation is a string that is computed as follows: for each…
题目链接:https://cn.vjudge.net/problem/HDU-4055 题意 给一个序列相邻元素各个上升下降情况('I'上升'D'下降'?'随便),问有几种满足的排列. 例:ID 答:2 (231和132) 思路 第一次看这题,思路是没得. 又是最后讲题才知道咋写. 直接给方程了: dp[i][j]表示满足以j为结尾的,长度为i的排列方案数. str[i]=='I': dp[i][j]=sum(dp[i-1][k]) (1<=k<=j-1) str[i]=='D': dp[i]…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4055 思路:dp[i][j]表示处理前i个字符以j结尾可能的序列数. 当a[i]=='I'时,dp[i][j]=sum(dp[i-1][k]),(1<=k<=j-1), 可进一步化为dp[i][j-1]+dp[i-1][j-1]. 当a[i]=='D'时,dp[i][j]=sum(dp[i-1][k]),(j<=k<=i-1),可进一步化为dp[i][j+1]+dp[i-1][j].…
链接:HDU-4055:Number String 题意:给你一个字符串s,s[i] = 'D'表示排列中a[i] > a[i+1],s[i] = 'I'表示排列中a[i] < a[i+1],s[i]  = '?' 表示无限制. 题解:dp[i][j]表示前i个满足字符串条件的结尾为j的 i 的排列. 如果s[i - 1]是' I ',那么dp[i][j] = dp[i-1][1] + dp[i-1][2] + .. + dp[i-1][j-1] 如果s[i - 1]是‘D’,那么dp[i][…
[root@wx03 ~]# cat a17.pl use JSON qw/encode_json decode_json/ ; use Encode; my $data = [ { 'name' => 'Ken' , 'age' => 19 }, { 'name' => '测试' , 'age' => 25 } ]; ##解json格式 my $array = decode_json ( $data ); print "1111111111\n"; print…
Number String Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1016    Accepted Submission(s): 440 Problem Description The signature of a permutation is a string that is computed as follows: fo…
Number String 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4055 dp 定义状态:dp[i][j]为当strlen=i,数字结尾为j的方案数. 当为'I'时,dp[i][j]=∑dp[i-1][1...j-1];//若之前填过j,可以让前面j到i的数+1 当为'D'时,dp[i][j]=∑dp[i-1][j...i]; 当为'?'时,dp[i][j]=∑dp[i-1][1...i]. 于是我们有了O(n3)的算法: #includ…
Number string number Js只有一种数字类型(包括整型,浮点型) 极大或极小的可用科学计数法来表示.(7.7123e+1) 所有js数字均为64位 Js所有的数字都存储为浮点型 小数的最大位数是17位 0开头的为八进制 0x开头的为16进制 console.log(Number.MAX_VALUE); 最大值 console.log(Number.MIN_VALUE);最小值 console.log(Number.NEGATIVE_INFINITY);极大值 console.l…
HDU 4054 Number String 思路: 状态:dp[i][j]表示以j结尾i的排列 状态转移: 如果s[i - 1]是' I ',那么dp[i][j] = dp[i-1][j-1] + dp[i-1][j-2] + .. + dp[i-1][1] 如果s[i - 1]是‘D’,那么dp[i][j] = dp[i-1][j] + dp[i-1][j+1] + ... + dp[i-1][i] 用前缀和处理出sum[i][j]就不用dp[i][j]了 代码: #include<bits…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4055 Number String Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) 问题描述 The signature of a permutation is a string that is computed as follows: for each pair of consecut…