标签:blog http io ar for div art on c
1.http://www.rqnoj.cn/problem/1
program mingming; var a:array [1..1000] of integer; i,j,k,n:longint; begin fillchar(a,0,sizeof(a)); k:=0; read(n); for i:=1 to n do begin read(j); if a[j] <> 1 then begin a[j]:=1; inc(k); end; end; writeln(k); for i:=1 to 1000 do begin if a[i] = 1 then write(i,‘ ‘); end; end.
2.
#include <stdio.h> #define maxm 26 #define maxn 30001 int n,m; int v[maxm],w[maxm]; int f[maxn]={0}; int main(int argc, const char *argv[]) { // freopen("1.in","r",stdin); int i,j,k,l; scanf("%d%d",&n,&m); for(i=1;i<=m;i++) scanf("%d%d",&v[i],&w[i]); for(i=1;i<=m;i++) for(j=n;j>0;j--) { if(j>=v[i] && (f[j] < f[j-v[i]] + v[i]*w[i])) f[j] = f[j- v[i]] + v[i]*w[i]; } printf("%d",f[n]); return 0; }
3.
#include <stdio.h> #include <stdlib.h> char JamNum[27]={0}; char Snum[27]= {0}; int weishu,Start,End; int main() { char Schar,Echar,temp; int change; int i,j,k,l; scanf("%d%d%d",&Start,&End,&weishu); scanf("%s",Snum); //printf("%s",Snum); Schar=Start+‘a‘-1;Echar=End+‘a‘-1; //printf("%c %c",Schar,Echar); for(j=0;j<5;j++) { change = 26; for(i=weishu-1;i>=0;i--)//判断那一位可以改 { if(Snum[i]<Echar+i-weishu+1) { change=i; break; } } if(change == 26) return 0; temp=Snum[change]; for(i=change;i<weishu;i++) { Snum[i]=++temp; } printf("%s\n",Snum); } return 0; }
标签:blog http io ar for div art on c
原文地址:http://www.cnblogs.com/rainboy/p/3988299.html