hdu1085

Posted 白丁一枚

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了hdu1085相关的知识,希望对你有一定的参考价值。

/*
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int c1[8010], c2[8010];
int main() {
  int s[4], v[4] = {0, 1, 2, 5};
  while (scanf("%d%d%d", &s[1], &s[2], &s[3]) != EOF) {
      if (s[1] == 0 && s[2] == 0 && s[3] == 0) break;
      int sum = 0;
      sum+=s[1] + s[2]*v[2] + s[3]*v[3];
        memset(c1, 0, sizeof(c1));
        for (int i = 0; i <= s[1]; i++) {
            c1[i] = 1;
        }
        memset(c2, 0, sizeof(c2));
        for (int i = 2; i <= 3; i++) {
            for (int j = 0; j <= sum; j++) {
                for (int k = 0, count = 0; count<=s[i]&&k+j <= sum; k+=v[i], count++) {
                    c2[k+j] += c1[j];
                }
            }
            for (int j = 0; j<= sum; j++) {
                c1[j] = c2[j];
                c2[j] = 0;
            }
        }
    for(int j=0; j <= sum; j++){
            if(c1[j]==0){
                printf("%d\n",j);
                break;
            }
        }
    }
}*/
#include<iostream>
#include<cstring>
using namespace std;
const int MAX = 8000;
int arr[MAX+10], brr[MAX+10];
int main() {
  int s[4];
  int v[4]={0, 1, 2, 5};
  while (cin>>s[1]>>s[2]>>s[3]) {
    if (s[1]==0&&s[2]==0&&s[3]==0)
      return 0;
    int n = 0;
    for (int i = 1; i <= 3; i++)
      n+=s[i]*v[i];
    memset(arr,0,sizeof(arr));
    memset(brr,0,sizeof(brr));
    arr[0] = 1;
    for (int i = 1; i <= 3; i++) {
      for (int j = 0; j <= n; j++) {
        for (int k =0, count = 0; count <= s[i] && j+k <= n; k+=v[i],count++) {
          brr[j+k] += arr[j];
        }
      }
      for (int l =0; l <= n; l++) {
        arr[l] = brr[l];
        brr[l] = 0;
      }
    }
    int a;
    for (a = 1; a <= n; a++) {
      if (arr[a] == 0)
        break;
    }    
    cout<<a<<endl;
  }
  return 0;
} 

 

以上是关于hdu1085的主要内容,如果未能解决你的问题,请参考以下文章

hdu1085

hdu 1085(普通母函数)

HDU - 1085 母函数

HDU 1085 Holding Bin-Laden Captive!

hdu 1085 Holding Bin-Laden Captive!(母函数)

HDU--1085--Holding Bin-Laden Captive!(母函数)