原题:http://acm.hdu.edu.cn/showproblem.php?pid=1085
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
const int maxn = 1e4;
int dp[maxn], tmp[maxn];
int a, b, c;
int main(){
while(cin>>a>>b>>c){
if(a==0 && b==0 && c==0) break;
int maxx = a+2*b+5*c;
memset(dp, 0, sizeof dp);
memset(tmp, 0, sizeof tmp);
for(int i = 0;i<=a;i++)
dp[i] = 1;
for(int i = 0;i<=a;i++){
for(int j = 0;j<=2*b;j+=2){
tmp[i+j] += dp[i];
}
}
for(int i = 0;i<=a+2*b;i++){
dp[i] = tmp[i];
tmp[i] = 0;
}
for(int i = 0;i<=a+2*b;i++){
for(int j = 0;j<=5*c;j+=5){
tmp[i+j] += dp[i];
}
}
int ans = 0;
for(int i = 0;i<=maxx;i++){
dp[i] = tmp[i];
if(dp[i] == 0){
ans = i;
break;
}
}
if(ans == 0) ans = maxx+1;
cout<<ans<<endl;
}
return 0;
}