上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 42 下一页
枚举的时候体积和组中的物品顺序换了,果断WA深刻理解了,但又感觉不怎么会表达,囧#include<stdio.h>#include<string.h>int a[110][110];int dp[110];int max(int a,int b){ return a>b?a:b;}int main(){ int i,j,m,n; while(scanf("%d%d",&n,&m),(n||m)) { for(i=1;i<=n;i++) for(j=1;j<=m;j++) scanf("%d",&a Read More
posted @ 2011-11-17 21:00 Because Of You Views(290) Comments(0) Diggs(0) Edit
View Code //要注意dp转移的时候两重循环的顺序,w[x](鞋子的价格) 可能为0,如果换一下顺序可能会导致某双鞋被选了两次#include<stdio.h>#include<string.h>int dp[11][10010];int belong[10010];int w[10010],v[10010];int flag[20];int max(int a,int b){ return a>b?a:b;}int main(){ int n,m,k,i,j; while(scanf("%d%d%d",&n,&m,&a Read More
posted @ 2011-11-17 19:57 Because Of You Views(536) Comments(2) Diggs(0) Edit
dp[i]代表抢到i的钱且不被抓住的最大概率1-dp[i]就是被抓住的最小概率easy~#include<stdio.h>#include<string.h>double a[110],dp[10010];int m[110];double max(double a,double b){ return a>b?a:b;}int main(){ int t,i,j,n,k; double P; scanf("%d",&t); while(t--) { scanf("%lf%d",&P,&n); int Read More
posted @ 2011-11-17 19:05 Because Of You Views(231) Comments(0) Diggs(0) Edit
注意,求的是最大的概率,所以先求出不能被录取的最小的概率p,然后直接1-p即可WA了两次原因:初始化的时候dp[0]没有赋值#include<stdio.h>#include<string.h>double dp[10010];int a[1010];double b[1010];double min(double a,double b){ return a<b?a:b;}int main(){ int n,m,i,j,k; while(scanf("%d%d",&n,&m),(n||m)) { for(i=1;i<=m; Read More
posted @ 2011-11-17 17:30 Because Of You Views(183) Comments(0) Diggs(0) Edit
Let's go homeTime Limit: 10000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 693Accepted Submission(s): 220Problem Description小时候,乡愁是一枚小小的邮票,我在这头,母亲在那头。—— 余光中集训是辛苦的,道路是坎坷的,休息还是必须的。经过一段时间的训练,lcy决定让大家回家放松一下,但是训练还是得照常进行,lcy想出了如下回家规定,每一个队(三人一队)或者队长留下或者其余两名队员同时留下; Read More
posted @ 2011-11-17 17:03 Because Of You Views(346) Comments(0) Diggs(0) Edit
题目看了好久,囧!dp[i][j]表示前i节车厢用j个火车头去拉所能拉的最大乘客量#include<stdio.h>#include<string.h>int dp[55555][4],a[55555];int max(int a,int b){ return a>b?a:b;}int main(){ int t,i,j,k,n,m; scanf("%d",&t); while(t--) { scanf("%d",&n); a[0]=0; for(i=1;i<=n;i++) scanf("%d Read More
posted @ 2011-11-17 16:23 Because Of You Views(205) Comments(0) Diggs(0) Edit
dp[i][j]代表能否组成一边长为i和一边长为j的三角形,剩下的一边就是sum-i-j了接下来就是背包的做法了#include<stdio.h>#include<math.h>#include<string.h>bool dp[810][810];int get_area(int x,int y,int z){ double p=(x+y+z)/2.0; return int(sqrt(p*(p-x)*(p-y)*(p-z))*100);}int max(int a,int b){ return a>b?a:b;}int a[50];int main Read More
posted @ 2011-11-17 15:36 Because Of You Views(440) Comments(0) Diggs(0) Edit
有个小技巧,因为力矩可能为负数,就把所有的力矩都加上一个值(加上后保证为正数就好),最后输出组成这个数的方案数#include<stdio.h>#include<string.h>int pos[30],w[30];int dp[21][4000];int main(){ int C,G; int i,j,k; scanf("%d%d",&C,&G); for(i=1;i<=C;i++) scanf("%d",&pos[i]); for(i=1;i<=G;i++) scanf("%d& Read More
posted @ 2011-11-17 06:50 Because Of You Views(248) Comments(0) Diggs(0) Edit
把取余神马的都提前处理掉,可以加快速度(bool)dp[i][j]=dp[i-1][j-a[i]]||dp[i-1][j+a[i]]#include<stdio.h>#include<string.h>int a[10001];bool dp[10001][101];int n,m;int main(){ int i,j; scanf("%d%d",&n,&m); for(i=1;i<=n;i++) { scanf("%d",&a[i]); while(a[i]<0) a[i]+=m; a[i] Read More
posted @ 2011-11-17 05:22 Because Of You Views(163) Comments(0) Diggs(0) Edit
#include<stdio.h>#include<string.h>int m,n;char str[15][15];int col[110][22];bool dp[200000];int t[110],s[110],g[110][110];int getid(char *s){ for(int i=0;i<m;i++) if(strcmp(s,str[i])==0) return i; return 0;}int main(){ int i,j,k; char tmp[15]; while(scanf("%d%d",&m,& Read More
posted @ 2011-11-17 05:17 Because Of You Views(251) Comments(0) Diggs(0) Edit
上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 42 下一页