标签:style blog http color os io ar for div
http://acm.sdut.edu.cn/sdutoj/problem.php?action=seach
#include <stdio.h> #include <stdlib.h> #include <string.h> int V; int f[100001]; int c[3] = {0,150,200,350}; int ans; int max(int a,int b) { return a>b?a:b; } int main() { int t,i,j; int V; scanf("%d",&t); while(t--) { memset(f,0,sizeof(f)); scanf("%d",&V); for(i = 1;i<=3;i++) { for(j = c[i];j<=V;j++) { f[j] = max(f[j],f[j - c[i]] + c[i]); } } printf("%d\n",V - f[V]); } return 0; }
#include <stdio.h> #include <string.h> #include <stdlib.h> int dg[5000000]; int main() { int w[50]; int n,m,j,i,k,x,y; int a,b,c,flag,s; double q,z,g; char str; while(scanf("%lf %d",&q,&n),n) { k=0; y=q*100; while(n--) { a=0; b=0; c=0; s=0; flag=0; scanf("%d",&m); while(m--) { getchar(); scanf("%c:%lf",&str,&z); if(str==‘A‘) a+=z*100; else if(str==‘B‘) b+=z*100; else if(str==‘C‘) c+=z*100; else flag=1; if(a>60000||b>60000||c>60000) flag=1; } s=a+b+c; if(s<=100000&&flag!=1) { w[k++]=s; } } memset(dg,0,sizeof(dg)); for(i=0;i<k;i++) { for(j=y;j>=w[i];j--) { if(dg[j]<dg[j-w[i]]+w[i]) dg[j]=dg[j-w[i]]+w[i]; } } g=(dg[y]*1.0)/100; printf("%.2lf\n",g); } return 0; }
#include <stdio.h> #include <string.h> #include <stdlib.h> using namespace std; int f[1000]; int n,m; int c[1000]; int Min(int a,int b) { return a>b?b:a; } int main() { int i,j; int max; int pos; while(scanf("%d",&n),n) { max = 0; for(i = 1;i<=n;i++) { scanf("%d",&c[i]); if(max<c[i]) { max = c[i]; pos = i; } } c[pos] = 0; scanf("%d",&m); m = m-5; for(i = 0;i<=m;i++) f[i] = m; for(i = 1;i<=n;i++) { for(j = m;j>=c[i];j--) f[j] = Min(f[j],f[j - c[i]] - c[i]); } printf("%d\n",f[m] + 5 - max); } return 0; }
标签:style blog http color os io ar for div
原文地址:http://www.cnblogs.com/yangyongqian/p/3944188.html