为什么邮箱突然进不去了总提示正在进入不安全网站,网页设计图片中添加文字,悬停提示 wordpress,大型网站建设企业名录模板给定一组函数f1 ... fn(离散时间)和时间限制(int)#xff0c;应找到最大输出#xff0c;即在不同函数之间分配时间以最大化所用函数输出的总和。对于任何函数#xff0c;任何时候的值表示如果用于所述时间的函数的总输出。 即F(2)函数的总输出#xff0c;如果使用2秒。 不是…给定一组函数f1 ... fn(离散时间)和时间限制(int)应找到最大输出即在不同函数之间分配时间以最大化所用函数输出的总和。对于任何函数任何时候的值表示如果用于所述时间的函数的总输出。 即F(2)函数的总输出如果使用2秒。 不是F(1) F(2)。所有值(时间函数输出)都是整数。我的当前算法通过检查F(t)找到所有时间被放入一个函数的情况将最大值与前一个最大M(t-1)的所有可能输出的最大值进行比较找出可能损坏的最大值为每个可能的功能添加1秒(带有已使用功能和时间的记录)。public int computeDamage(){int totalTime calculator.getTotalTime();int numAttacks calculator.getNumAttacks();if(totalTime 0) return 0;int[] attackHist new int[numAttacks];return maxDamage(numAttacks, attackHist, 1, totalTime, 0);}public int maxDamage(int numAttacks, int[] attackHist, int start, int end, int max) {//get the max of all the values at f(start), save the attackint maxF -1, attack -1;for(int i 0; i numAttacks; i) {int dam calculator.calculateDamage(i, start);if(dam maxF) {maxF dam;attack i;}}//if start isnt 1, get the max of all possible values added to the attackHistint maxH -1, attackH -1;if(start 1) {for(int j 0; j numAttacks; j) {int dChange -1;if(attackHist[j] 0) dChange calculator.calculateDamage(j, attackHist[j]1) - calculator.calculateDamage(j, attackHist[j]);else dChange calculator.calculateDamage(j, attackHist[j]1);if((max dChange) maxH) {maxH max dChange;attackH j;}}//if max is greater, reset attackHist. Otherwise, add 1 to used attackif(maxF maxH) {Arrays.fill(attackHist, 0);attackHist[attack] start;max maxF;} else {attackHist[attackH];max maxH;}} else {//just set the max to maxFmax maxF;attackHist[attack] 1;}if(end start) return max;else return maxDamage(numAttacks, attackHist, start1, end, max);}输入12.in20 120 3 4 7 9 12 12 14 15 15 17 192 5 6 9 11 12 15 15 16 19 21 221 4 6 8 9 11 13 14 16 18 21 221 4 4 4 5 5 6 8 9 11 12 140 3 4 5 7 10 12 13 15 17 20 201 3 5 5 8 10 10 12 14 15 16 181 1 3 5 7 8 10 11 11 13 14 161 1 2 2 2 3 6 7 10 11 11 121 3 5 5 7 7 8 11 11 12 14 160 1 4 5 6 9 10 11 12 12 15 183 5 5 7 8 10 12 12 14 15 15 163 5 6 9 12 12 13 14 15 18 21 211 2 3 4 7 9 10 12 12 15 18 183 4 5 7 8 10 12 13 13 16 17 203 5 7 7 10 11 14 16 17 18 21 230 1 4 7 7 8 10 12 13 13 14 162 3 3 6 8 9 12 15 17 18 20 210 2 3 3 6 8 9 10 13 15 17 171 2 4 7 9 9 9 11 14 14 17 193 5 6 7 10 11 12 12 13 16 17 19第一行告诉我们有多少函数(20)和多少时间(12秒)来最大化输出。每一行都是一个定义为1到12 F(t)的函数详细说明了该函数在该点之前完成了多少损坏。输出应为31但我的代码输出为30。