摘要:
//此为背包问题 ,289为0-1背包 #include<stdio.h>#include<stdlib.h> typedef struct data { int w; int v; }data; int cmp(const void *a,const void *b){ return ((data*)a)->v-((data*)b)->v; }//不加括号不行啊 int main(){ data a[10]; int T,v,w,sum,s,m; scanf("%d",&T); while(T--) { sum=0; sca.. 阅读全文
摘要:
#include<stdio.h>#include<stdlib.h>#include<string.h>#define N 1001int ans[N];int max(int a,int b){if(a>b) return a; return b; }int main(){ int n,v,c,w; int max(int,int); while(scanf("%d%d",&n,&v),n||v) { memset(ans,0,sizeof(ans)); for(int i=1;i<=n;i++) { sc 阅读全文
摘要:
#include <stdio.h>int main(){int i,j,n,sum=0,x[1001]={0};scanf("%d",&n);for (i=1;i<=n;i++){scanf("%d",&j);if (x[j]==0) sum++;x[j]=1;}printf("%d\n",sum);for (i=1;i<=1000;i++)if (x[i]==1) printf("%d ",i);return 0;} 阅读全文