//...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%lld",&a)
#define sf2(a,b) scanf("%lld %lld",&a,&b)
#define sf3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld",a)
#define pf2(a,b) printf("%lld %lld",a,b)
#define pf3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
//const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
main()
{
long n,m,t;
while(cin>>n>>m>>t)
{
long ans=0,i,x,xx,tot,total=0,ar[100005];
memset(ar,-1,sizeof(ar));
for(i=0; i<=(t/n); i++)
{
xx=i*n;
x=t-xx;
if(x/m==0)
break;
tot=(x/m)+i;
total=((x/m)*m)+(i*n);
ar[total]=max(ar[total],tot);
if(t==total)
ans=max(ans,tot);
}
for(i=0; i<=(t/m); i++)
{
xx=i*m;
x=t-xx;
if(x/n==0)
break;
tot=(x/n)+i;
total=((x/n)*n)+(i*m);
ar[total]=max(ar[total],tot);
if(t==total)
ans=max(ans,tot);
}
if(ans==0)
{
long f=0;
for(i=t-1;i>=0;i--)
{
if(ar[i]>=0)
{
f=1;
cout<<ar[i]<<" "<<t-i<<endl;
break;
}
}
if(f==0)
{
cout<<0<<" "<<t<<endl;
}
}
else
cout<<ans<<endl;
}
}
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%lld",&a)
#define sf2(a,b) scanf("%lld %lld",&a,&b)
#define sf3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld",a)
#define pf2(a,b) printf("%lld %lld",a,b)
#define pf3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
//const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
main()
{
long n,m,t;
while(cin>>n>>m>>t)
{
long ans=0,i,x,xx,tot,total=0,ar[100005];
memset(ar,-1,sizeof(ar));
for(i=0; i<=(t/n); i++)
{
xx=i*n;
x=t-xx;
if(x/m==0)
break;
tot=(x/m)+i;
total=((x/m)*m)+(i*n);
ar[total]=max(ar[total],tot);
if(t==total)
ans=max(ans,tot);
}
for(i=0; i<=(t/m); i++)
{
xx=i*m;
x=t-xx;
if(x/n==0)
break;
tot=(x/n)+i;
total=((x/n)*n)+(i*m);
ar[total]=max(ar[total],tot);
if(t==total)
ans=max(ans,tot);
}
if(ans==0)
{
long f=0;
for(i=t-1;i>=0;i--)
{
if(ar[i]>=0)
{
f=1;
cout<<ar[i]<<" "<<t-i<<endl;
break;
}
}
if(f==0)
{
cout<<0<<" "<<t<<endl;
}
}
else
cout<<ans<<endl;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন