diff --git a/BZOJ/Readme.md b/BZOJ/Readme.md new file mode 100644 index 0000000..eaeb1dc --- /dev/null +++ b/BZOJ/Readme.md @@ -0,0 +1,2 @@ +#大视野在线测评 +[Goto BZOJ Home Page](http://www.lydsy.com/JudgeOnline/ "Welcome to BZOJ") diff --git a/POJ/1170.cpp b/POJ/1170.cpp new file mode 100644 index 0000000..82140d6 --- /dev/null +++ b/POJ/1170.cpp @@ -0,0 +1,102 @@ +#include +#include +#include +#include +using namespace std; + +/// ItemID[0]=7 stands for "When C=7, This object id is 0" +int ItemID[6]; +/// Amount of Item with ID. +int ItemAmount[6]; +/// Price of Item with ID. +int ItemPrice[6]; + +#define MAX_INT 1e9 + +/// Bucket +int b; +/// Special Combinations. +int s; + +///Array of DP +int dp[6][6][6][6][6]; + +int special_combine[1000][6]; +int special_price[1000]; + +void Solve() +{ + /// May be dangerous. + memset(dp,-1,sizeof(dp)); + + dp[0][0][0][0][0]=0; + /// i,j,k,x,y respects the amount of selected Item, from 0 to 5 + for(int i=0;i<=ItemAmount[0];i++) + { + for(int j=0;j<=ItemAmount[1];j++) + { + for(int k=0;k<=ItemAmount[2];k++) + { + for(int x=0;x<=ItemAmount[3];x++) + { + for(int y=0;y<=ItemAmount[4];y++) + { + int FinalPrice = MAX_INT; + int TempPrice = MAX_INT; + /// Try Each Special Combination + for(int si=0;si=special_combine[si][0]&&j>=special_combine[si][1]&&k>=special_combine[si][2]&&x>=special_combine[si][3]&&y>=special_combine[si][4]) + { + TempPrice = dp[i-special_combine[si][0]][j-special_combine[si][1]][k-special_combine[si][2]][x-special_combine[si][3]][y-special_combine[si][4]] +special_price[si]; + FinalPrice = min(FinalPrice,TempPrice); + } + } + if(FinalPrice!=MAX_INT) + { + dp[i][j][k][x][y]=FinalPrice; + } + else + { + /// Just Calculate the original price + dp[i][j][k][x][y]=i*ItemPrice[0]+j*ItemPrice[1]+k*ItemPrice[2]+x*ItemPrice[3]+y*ItemPrice[4]; + } + } + } + } + } + } +} + +int main() +{ + scanf("%d",&b); + for(int i=0;i +#define sample scanf("%d", &b); +#define hahaha printf("/\\ /\\\n _"); +#define outspace printf(" "); +#define bigchange printf("\n"); + +int main() +{ + int a; + scanf("%d", &a); + for(int i = 0, b; i < a; i++) + { + sample + if(b == 1) + { + hahaha + } + else + { + printf("\n"); + for(int j = 0; j < b; j++) + { + for(int k = 0; k < b-j-1; k++) + { + outspace + } + printf("/"); + for(int k = 0; k < j*2; k++) + { + outspace + } + printf("\\"); + for(int k = 0; k < b*3-(j+1)*2; k++) + { + outspace + } + printf("/"); + for(int k = 0; k < j*2; k++) + { + outspace + } + printf("\\"); + bigchange + } + for(int j = 0; j < b-1; j++) + { + bigchange + } + for(int j = 0; j < b*2; j++) + { + outspace + } + for(int j = 0; j < b; j++) + { + printf("_"); + } + } + bigchange + } + return 0; +} diff --git a/VIJOS/1313_hzwer.cpp b/VIJOS/1313_hzwer.cpp new file mode 100644 index 0000000..06ef01f --- /dev/null +++ b/VIJOS/1313_hzwer.cpp @@ -0,0 +1,35 @@ +#include +using namespace std; +int main() +{ + int a,b,mx=0; + int i,j; + int m,n,v[61]={0},p[61]={0},q; + int v1[61]={0},v2[61]={0},p1[61]={0},p2[61]={0}; + int f[50001]={0}; + cin>>m>>n; + m/=10; + for(i=1;i<=n;i++) + { + cin>>a>>b>>q; + a/=10; + if(q!=0) + { + if(v1[q]==0){v1[q]=a;p1[q]=b;} + else {v2[q]=a;p2[q]=b;} + } + else {v[i]=a;p[i]=b;} + } + for(int i=1;i<=n;i++) + for(int j=m;j>=v[i];j--) + { + f[j]=max(f[j],f[j-v[i]]+v[i]*p[i]); + if(j-v1[i]-v[i]>=0)f[j]=max(f[j],f[j-v1[i]-v[i]]+v1[i]*p1[i]+v[i]*p[i]); + if(j-v2[i]-v[i]>=0)f[j]=max(f[j],f[j-v2[i]-v[i]]+v2[i]*p2[i]+v[i]*p[i]); + if(j-v1[i]-v2[i]-v[i]>=0)f[j]=max(f[j],f[j-v1[i]-v2[i]-v[i]]+v1[i]*p1[i]+v2[i]*p2[i]+v[i]*p[i]); + mx=max(f[j],mx); + } + cout< + +int numThing[100]; +int costs[100][5]; +int values[100][5]; + +int dp[3201]; + +int MAX(int a, int b){ + return a>b ? a:b; +} +int main(){ + int limit, num; + int cost, value, index, i, k; + + scanf("%d %d", &limit, &num); + limit /= 10; + for(i=0; i<=num; i++) + numThing[i] = 0; + for(i=0; i=costs[i][0]; k--){ + switch(numThing[i]){ + case 3: + if(k-costs[i][0]-costs[i][1]-costs[i][2] >= 0) + dp[k] = MAX(dp[k], dp[k-costs[i][0]-costs[i][1]-costs[i][2]] + values[i][0]*costs[i][0] + values[i][1]*costs[i][1] + values[i][2]*costs[i][2]); + case 2: + if(k-costs[i][0]-costs[i][1] >= 0) + dp[k] = MAX(dp[k], dp[k-costs[i][0]-costs[i][1]] + values[i][0]*costs[i][0] + values[i][1]*costs[i][1]); + if(k-costs[i][0]-costs[i][2] >= 0) + dp[k] = MAX(dp[k], dp[k-costs[i][0]-costs[i][2]] + values[i][0]*costs[i][0] + values[i][2]*costs[i][2]); + case 1: + dp[k] = MAX(dp[k], dp[k-costs[i][0]] + values[i][0]*costs[i][0]); + } + } + } + printf("%d\n", dp[limit]*10); + + return 0; +} diff --git a/VIJOS/1317.cpp b/VIJOS/1317.cpp new file mode 100644 index 0000000..8891798 --- /dev/null +++ b/VIJOS/1317.cpp @@ -0,0 +1,47 @@ +#include +#include +#include +#include +using namespace std; + +/// 0-1背包问题(一维数组空间优化) + +namespace Package1_SpaceOptimized +{ + const int MAXM = 30000 + 5; + const int MAXN = 25 + 5; + int ldp[MAXM]; + int w[MAXN]; + int v[MAXN]; + int N,M; + void solve() + { + for(int i=1;i<=N;i++) + { + for(int j=M;j>=1;j--)///从M到1逆序循环 + { + int a=ldp[j]; + int b=-1; + if(j-w[i]>=0) b=ldp[j-w[i]]+v[i]; + ldp[j]=max(a,b); + } + } + printf("%d\n",ldp[M]); + } + int main() + { + scanf("%d %d",&M,&N); + for(int i=1;i<=N;i++) + { + scanf("%d %d",&w[i],&v[i]); + v[i]=w[i]*v[i]; + } + solve(); + return 0; + } +} + +int main() +{ + return Package1_SpaceOptimized::main(); +} diff --git a/VIJOS/1317_hzwer.cpp b/VIJOS/1317_hzwer.cpp new file mode 100644 index 0000000..4917d54 --- /dev/null +++ b/VIJOS/1317_hzwer.cpp @@ -0,0 +1,19 @@ +#include +using namespace std; +int main() +{ +int m,n,i,v; +int w[25],c[25],f[30001]; +cin>>m>>n; +for(i=1;i<=n;i++) +{ +cin>>w[i]>>c[i]; +c[i]*=w[i]; +} +for(i=1;i<=n;i++) +for(v=m;v>=w[i];v--) +if(f[v]