点击这里更换您喜欢的皮肤wtboj 首页
请点击这里登入noios   首页 入门 c++讲义 入门教程视频 金牌教程 入门视频 站务 公告 | 题库 记录 竞测 测试 闯关 作业 排名 团队 讨论 | 换肤 | 登入 注册  
News >>   新增功能:各团队管理员可以发布本团队作业了 ()

From sina007
哥德巴赫猜想
讨论 Discussion
 
.
#include<iostream>
#include<cstdio>
using namespace std;
int n,t,a[101]={0},v[101]={0},vm=0,km[101][1001]={0};
int f(int x,int s,int y){
if(x>n){if (y>vm)vm=y;
return 0;
}
if(y+v[x]<km[x][s-a[x]])return 0;
if(s>=a[x]) {
if(y+v[x]>=km[x][s-a[x]])km[x][s-a[x]]=y+v[x];
f(x+1,s-a[x],y+v[x]);
}
f(x+1,s,y);
}
int main(){
freopen("p1105.in","r",stdin);
freopen("p1105.out","w",stdout);
scanf("%d %d\n",&t,&n);
int i;
for(i=1;i<=n;i++){
scanf("%d %d",&a[i],&v[i]);
}
f(1,t,0);
printf("%d",vm);
fclose(stdin);
fclose(stdout);
}
( )

此主题无回复显示
发布讨论主题 回复讨论主题
Flag
  
题号
  P1576
  其它
通过
  27人
提交
  85次
通过率
  32%
难度
  1
提交 讨论 题解
 Copyright wtboj © 2005-2006. www.wutuobang.date Powered by wtboj 关于 联系 帮助
 wtboj Information ---- Total Users : 1362 | Online Users / Processes : 0 / 78 | Processed Time : 31 ms | Server Time : 2025/12/16 21:27:19