-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10465_homerSimpson.cpp
More file actions
63 lines (57 loc) · 901 Bytes
/
10465_homerSimpson.cpp
File metadata and controls
63 lines (57 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<iostream>
#include<cstring>
using namespace std;
#define max(a,b) a>b?a:b
void swap(int *m,int *n)
{
int temp;
temp=*m;
*m=*n;
*n=temp;
}
int main()
{
int m,n,t,i,arr[10030];
while(cin>>m>>n>>t)
{
if(m>n)
swap(m,n);
memset(arr,0,sizeof arr);
arr[m]=arr[n]=1;
for(i=m;i<=t;i++)
{
if(arr[i])
{
arr[i+m]=max(arr[i+m],arr[i]+1);
arr[i+n]=max(arr[i+n],arr[i]+1);
}
if(i+m>t)
break;
}
if(arr[t])
cout<<arr[t]<<endl;
else
{
i=t-1;
while(arr[i]==0&&i>0)
i--;
cout<<arr[i]<<" "<<t-i<<endl;
}
}
return 0;
}
/*Critical Input :
852 965 9999
96 52 50
48 52 55
6 9 96
3 5 2
3 5 4
Critical output :
11 62
0 50
1 3
16
0 2
1 1
*/