摘要:
01背包View Code 1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<iostream> 5 using namespace std; 6 int wi[10000],f[1000050]; 7 int main(){ 8 int i,fmax,n,sum,j; 9 while(scanf("%d%d",&n,&fmax)==2){10 for(i=1,sum=0;i<=n;i++){11 scanf(&qu 阅读全文
摘要:
View Code 1 #include<cstdio> 2 #include<cstdlib> 3 #define N 12 4 int f[N][N]; 5 6 int init(int m,int n){ 7 int i,j; 8 if(m==1||n==1)return 1; 9 else if(m==n) return init(m,n-1)+1;10 else if(m<n) return init(m,m);11 else if(m>n) return init(m,n-1)+init(m-n,n);12 }13 14 int main... 阅读全文
摘要:
这道题主要注意精度问题就行。还有就是二分的时候,left=mid+1或者left=mid;都行。不过个人更喜欢mid+1。View Code 1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #define eps 0.0000000001 5 using namespace std; 6 double n,p; 7 void solve(){ 8 long long right,left,mid; 9 double tmp;10 left=0;11 right=1000000002;12 阅读全文
摘要:
View Code 1 #include<cstdio> 2 #include<cstring> 3 #define N 4 4 int map[N+1][N+1]; 5 int main(){ 6 int i,j,k,ans; 7 char c; 8 memset(map,0,sizeof(map)); 9 ans=0;10 for(i=0;i<N;i++){11 for(j=0;j<N;j++){12 scanf("%c",&c);13 if(j==3)getchar();14 ... 阅读全文