10465

#include <iostream>
#include <cstdio>
#include <fstream>

#define INF 100000000
#define ll long long
using namespace std;

int m,n,MX;

int main()
{
	int tt;
	ll dp;
	int MN_Rem,MXR;

	while(scanf("%d%d%d",&m,&n,&tt)!=EOF)
	{
		if(m>tt && n>tt)
		{
			cout<<0<<" "<<tt<<"\n";
			continue;
		}
		MX =0;
		bool f =false;
		MN_Rem = INF;
		MXR = 0;
		for(int i=0;i<=10005;i++)
		{
			for(int j=0;j<=10005;j++)
			{
				dp =tt-(i*m+j*n);
				if(i==0 && j==0)
				continue;
				if(dp<0)//dp[i][j]
				break;
				if(dp==0)//dp[i][j]
				{
					if(MX<(i+j))
					MX = i+j;
					f=1;
				}
				if(dp>0)//dp[i][j]
				{
					if(dp<MN_Rem)//dp[i][j]
					{
						MN_Rem = dp;//dp[i][j]
						MXR = i+j;
					}
					else if(dp==MN_Rem)//dp[i][j]
					{
						if(MXR<(i+j))
						MXR = i+j;
					}
				}

			}//2nd for
		}//1st for

		if(f)
		cout<<MX<<"\n";
		else
		cout<<MXR<<" "<<MN_Rem<<"\n";
	}
	//out.close();
}

Leave a Reply

Your email address will not be published. Required fields are marked *