当前位置: 首页 > news >正文

网站建设怎么报印花税网站建设中文百

网站建设怎么报印花税,网站建设中文百,手机活动网站模板,手机网站模板制作js \n直接显示字符串Problem statement: 问题陈述#xff1a; You need to display N similar characters on a screen. You are allowed to do three types of operation each time. 您需要在屏幕上显示N个相似的字符。 每次允许您执行三种类型的操作。 You can insert a c…js \n直接显示字符串Problem statement: 问题陈述 You need to display N similar characters on a screen. You are allowed to do three types of operation each time. 您需要在屏幕上显示N个相似的字符。 每次允许您执行三种类型的操作。 You can insert a character, 您可以插入一个字符 You can delete the last character 您可以删除最后一个字符 You can copy and paste all displayed characters. After copy operation count of total written character will become twice. 您可以复制并粘贴所有显示的字符。 复制操作后总书写字符数将变为两倍。 All the operations are assigned different times. 所有操作均分配有不同的时间。 Time for insertion is X 插入时间为X Time for deletion is Y 删除时间为Y Time for copy, paste is Z 复制时间粘贴为Z You need to output minimum time to display N characters on the screen using these operations. 使用这些操作您需要输出最短时间以在屏幕上显示N个字符 。 Input: 输入 The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer N denoting the number of same characters to write on the screen. The next line contains time for insertion, deletion, and copying respectively. 输入的第一行包含一个整数T表示测试用例的数量。 然后是T测试用例。 每个测试用例都包含一个整数N该整数N表示要在屏幕上写入的相同字符的数量。 下一行分别包含插入删除和复制的时间。 Output: 输出 Print the minimum time to display N characters on the screen. 打印最短时间以在屏幕上显示N个字符。 Constraints: 限制条件 1 T 100 1 N 100 1 X, Y, Z N Example: 例 Input: Test case: 2 First test case, N, number of characters to be displayed 9 Value of X, Y, Z respectively, 1 2 1 N, number of characters to be displayed 10 Value of X, Y, Z respectively, 2 5 4 Output: minimum time for first test case: 5 minimum time for second test case: 14 Explanation: 说明 For the first test case no of character to be displayed is: 9 Time for insertion is 1 Time for deletion is 2 Time for copy paste is 1 Say the similar character is a So the best way is Insert two character Time is 2 Copy paste Total character so far is 4 Total time 3 Copy paste again Total character so far is 8 Total time 4 Insert gain Total character so far is 9 Total time 5 This is the most optimum way we can solve this Solution Approach: 解决方法 This is a recursive problem 这是一个递归问题 And we have a few possibilities, 我们有几种可能性 Simply insert 只需插入 Copy-paste 复制粘贴 Delete 删除 Now we need to understand the optimal option based on the situation 现在我们需要根据情况了解最佳选择 Say a situation where we need to reach character 13 and we are at character 7 displayed already 假设有一种情况我们需要到达第13个字符并且已经显示了第7个字符 Also, Cost of Inserting 6 digits is much higher than one-time copy paste and deleting ( just consider this case, it may not happen always if copy paste option is costly)  另外插入6位数字的成本比一次性复制粘贴和删除要高得多(仅考虑这种情况如果复制粘贴选项成本很高则可能不会总是发生) So, the question is when the delete options is useful 因此问题在于何时使用“删除”选项 Its useful for such case what I mentioned. So if we formulate the recursion 我提到的这种情况对这种情况很有用。 所以如果我们制定递归 Say, 说 N number of characters to be displayed. N 要显示的字符数。 So, if n is odd only then we need deletion if n is we even dont need that. 所以如果n是奇数只有这样我们需要删除如果n是我们甚至不需要这样。 Now, we have our recursion, so we can write the recursive function. Since there will be many overlapping sub-problems, we can wither use top-down DP or bottom-up DP. I have used memoization in my implementation. As an exercise, you should be able to convert the above recursion to tabulation DP. 现在我们有了递归因此我们可以编写递归函数。 由于将存在许多重叠的子问题因此我们可以使用自顶向下的DP或自底向上的DP。 我在实现中使用了记忆。 作为练习您应该能够将上述递归转换为表格DP。 C Implementation: C 实现 #include bits/stdc.h using namespace std; int dp[101]; int minimum(int a, int b) { return a b ? b : a; } int my(int cur, int x, int y, int z) { if (cur 1) { return x; } // meoization, dont compute whats already computed if (dp[cur] ! -1) return dp[cur]; if (cur % 2 0) { //for even n dp[cur] minimum(x my(cur - 1, x, y, z), z my(cur / 2, x, y, z)); } else { //for odd n dp[cur] minimum(x my(cur - 1, x, y, z), z y my((cur 1) / 2, x, y, z)); } return dp[cur]; } int main() { int t, n, item; cout enter number of testcase\n; cin t; for (int i 0; i t; i) { cout Enter number of characters\n; cin n; int x, y, z; cout Insert time for insertion, deletion and copy respectively\n; cin x y z; for (int i 0; i n; i) dp[i] -1; cout Minimum time is: my(n, x, y, z) endl; } return 0; } Output: 输出 enter number of testcase 3 Enter number of characters 8 Insert time for insertion, deletion and copy respectively 3 2 5 Minimum time is: 16 Enter number of characters 8 Insert time for insertion, deletion and copy respectively 1 1 3 Minimum time is: 7 Enter number of characters 3 Insert time for insertion, deletion and copy respectively 1 4 6 Minimum time is: 3 翻译自: https://www.includehelp.com/icp/minimum-time-to-display-n-character.aspxjs \n直接显示字符串
http://www.yutouwan.com/news/114742/

相关文章:

  • 沈阳市网站建设慢慢来做网站多少钱
  • 网站设计模板含数据库防封域名
  • 农家乐网站源代码wordpress下载付费
  • 阳春做网站网站开发电脑内存要多少
  • 网站开发ceac证网站设计抄袭
  • 网络网站公司废品回收在哪个网站做效果好
  • 做网站发违规内容 网警抓不抓国外网站阻止国内访问怎么做
  • 微信微网站怎么做鸿蒙最新版本
  • 网站怎么做地区屏蔽js北京网络网站建设价格
  • 百度网站排名抓取规则厦门行业网站建设
  • 企业门户网站开发任务书佛山 品牌设计
  • 怎么在手机上制作网站吗零售空间设计公司
  • 合肥市网站制作网页访问紧急升级
  • 关于建设教体局网站的申请网站开发的软 硬件环境标准
  • 渠道建设网站怎么当网站站长
  • 网站设计教科书东莞市网上注册公司流程
  • 做旅游攻略去什么网站好移动卡套餐
  • 网站建设需要多少钱小江专业做网站公司排名
  • 电商网站设计的准则是什么佛山网警
  • 建设手表商城网站多少钱北京文化馆设计公司哪种
  • 淘客个人网站怎么建设定制头像软件
  • 企业网站建立平台浅析小型企业网站的建设
  • 淘宝网站的论坛做的怎么样企业官网网站
  • 正规外贸网站建设公司网站的构成要素
  • 佛山优化企业网站排名平台我国数字经济报告
  • wap网站微信一键登录浦东新区专业做网站
  • 温州论坛吧海阳seo排名
  • 教做衣服的网站有哪些网站建设公司 电话销售没什么效果
  • 电子商务网站怎么做wordpress文章地址
  • 建设信用卡银行积分兑换商城网站广告图片在线制作