简单完全背包
#include <iostream>
#include <cstring>
using namespace std;
int dp[10001];
int max(int a,int b)
{
return a>b?a:b;
}
int main()
{
int a,b,t;
while (cin>>a>>b>>t)
{
memset (dp,0,sizeof(dp));
dp[0]=1;
for (int i=a;i<=t;i++)
if (dp[i-a]>=1)
{
dp[i]=max(dp[i],dp[i-a]+1);
}
for (int i=b;i<=t;i++)
if (dp[i-b]>=1)
dp[i]=max(dp[i],dp[i-b]+1);
int ans;
for (int i=t;i>=0;i--)
if (dp[i])
{
ans=i;
break;
}
cout<<dp[ans]-1;
if (t-ans>0)
cout<<" "<<t-ans;
cout<<endl;
}
}