acm程序设计之dp(编辑修改稿)内容摘要:

sists of several test cases. Each line of the input contains an integer k where 0 = k = 500000. The last line contains an integer −1, which should not be processed. 2020/9/16 14  output  For each k given in the input, print one line containing ak to the output. 2020/9/16 15  sample_input  7  10000  1 sample_output 20 18658 2020/9/16 16 分析:从下往上,打表也行  define size 500000  int data[size+1]。  bool inp[size*10]。 2020/9/16 17 int main(int argc, char *argv[]) {  int n。  memset(inp,false,sizeof(inp))。  data[0]=0。 inp[0]=true。  for(int i=1。 i=500000。 i++)  {  if (data[i1]i0amp。 amp。 inp[data[i1]i]==false)  data[i]=data[i1]i。  else  data[i]=data[i1]+i。  inp[data[i]]=true。  } 2020/9/16 18  while(cinnamp。 amp。 n!=1)  {  coutdata[n]endl。  }  system(PAUSE)。  return EXIT_SUCCESS。  } 2020/9/16 19 滑雪 nefu18  description  每到冬天 ,信息学院的张健老师总爱到二龙山去滑雪 ,喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。 可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。 张老师想知道载一个区域中最长底滑坡。 区域由一个二维数组给出。 数组的每个数字代表点的高度。 2020/9/16 20  input  输入的第一行表示区域的行数 R和列数 C(1 = R,C = 100)。 下面是 R行,每行有 C个整数,代表高度 h, 0=h=10000。  output  输出最长区域的长度。 2020/9/16 21  sample_input  5 5 。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。