http://acm.hdu.edu.cn/showproblem.php?pid=1085
//1304713 2009-04-24 16:34:31 Accepted 1085 156MS 324K 728 B C++ no way 
#include<iostream>
using namespace std;
int main()
{
    
int num[3];
    
int t[3]={1,2,5};
    
while(cin>>num[0]>>num[1]>>num[2])
    
{
        
if(num[0== 0 && num[1== 0 && num[2== 0)
            
break;

        
int outs[8005],temp[8005],i,j,k,s,N=0;

        
for(i=0;i<3;i++)
            N 
+= t[i] * num[i];

        
for(i=0;i<=N+1;i++)
            outs[i] 
= temp[i] = 0;

        
for(i=0;i<=num[0];i++//一定要有底层
            outs[i] = 1;

        
for(i=1;i<=2;i++//
        {
            
for(j=0;j<=N;j++
            
{
                   if(outs[j] == 0)
                        continue;
                
for(k=0,s=0; k+<= N && s<=num[i] ;s++, k+=t[i]) //注意个数的控制~
                {
                    temp[k
+j] += outs[j];
                }

            }

            
for(j=0;j<=N;j++)
            
{
                outs[j] 
= temp[j];
                temp[j] 
= 0;
            }

        }


        
for(i=1;i<=N+1;i++)
            
if(outs[i] == 0)
                
break;
        cout
<<i<<endl;
    }

    
return 0;
}