惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
W
WeLiveSecurity
Stack Overflow Blog
Stack Overflow Blog
L
LangChain Blog
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
F
Full Disclosure
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The Register - Security
The Register - Security
G
Google Developers Blog
C
Check Point Blog
GbyAI
GbyAI
A
About on SuperTechFans
V
Vulnerabilities – Threatpost
T
The Blog of Author Tim Ferriss
T
Tor Project blog
AWS News Blog
AWS News Blog
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
MongoDB | Blog
MongoDB | Blog
Latest news
Latest news
aimingoo的专栏
aimingoo的专栏
U
Unit 42
Y
Y Combinator Blog
P
Privacy International News Feed
Cisco Talos Blog
Cisco Talos Blog
S
Securelist
S
Schneier on Security
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Attack and Defense Labs
Attack and Defense Labs
P
Proofpoint News Feed
C
Cisco Blogs
Webroot Blog
Webroot Blog
T
Troy Hunt's Blog
Google Online Security Blog
Google Online Security Blog
月光博客
月光博客
P
Privacy & Cybersecurity Law Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
罗磊的独立博客
Cloudbric
Cloudbric
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hacker News: Ask HN
Hacker News: Ask HN
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 司徒正美
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Security Blog
Microsoft Security Blog

博客园 - saintqdd

hdu 1102 pku 2421 解题报告 pku 2777 Count Color 解体报告 nkoj1139和乘积最大那题一样. A Tour in Loquat Orchard (FZU 2007 ICPC Qualification Round I tzw) 最大黑区域 滑雪 一道经典题,humble number 今天碰到了一个很诡异的题,Alphacode (zoj 2202) 这两天经常碰到dp题,就写了一个0-1背包 实训以来,到这里的次数少了! 郁闷,乘积最大那题WA原来只是因为我用了pow函数引起的! Smith Number POJ强烈推荐50题 JOJ 2391 words POJ 1014 三十分钟掌握STL STL学习小记 POJ1006,中国剩余定理 POJ1003,简单题
石子合并问题
saintqdd · 2007-09-06 · via 博客园 - saintqdd

超经典的动态规划,我就不说了.

my code:

#include<stdio.h>
#include<memory.h>
int n;
int a[101],s[101][101],t[101][101];
int i,j,k,temp,max,min;
int main(){
  while(scanf("%d",&n)!=-1){
    i=1;
    while(i<=n){
      scanf("%d",&a[i++]);
    }
    memset(t,0,sizeof(t));
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
        for(k=i;k<=i+j-1;k++){
          if(k>n) temp=k%n;
          else temp=k;
          t[i][j]+=a[temp];
        }
      }
    }
    memset(s,0,sizeof(s));
    for(j=2;j<=n;j++){
      for(i=1;i<=n;i++){
        for(k=1;k<=j-1;k++){
          if(i+k>n) temp=(i+k)%n;
          else temp=i+k;
          max=s[i][k]+s[temp][j-k]+t[i][j];
          if(s[i][j]<max) s[i][j]=max;
        }
      }
    }
    max=0;
    for(i=1;i<=n;i++){
      if(max<s[i][n])
        max=s[i][n];
    }
    memset(s,0,sizeof(s));
    for(j=2;j<=n;j++){
      for(i=1;i<=n;i++){
        min=9999999;
        for(k=1;k<=j-1;k++){
          if(i+k>n) temp=(i+k)%n;
          else temp=i+k;
          s[i][j]=s[i][k]+s[temp][j-k]+t[i][j];
          if(min>s[i][j]) min=s[i][j];
        }
        s[i][j]=min;
      }
    }
    min=9999999;
    for(i=1;i<=n;i++){
      if(min>s[i][n])
        min=s[i][n];
    }
    printf("%d"n",min);
    printf("%d"n",max);
  }
}