Last active
September 17, 2018 17:32
-
-
Save abidkhan484/ce892575c910df24fe9b1a4ad82df2e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # not yet solved | |
| # a test case: 15 5 2 3 | |
| n, a, b, c = map(int, input().split()) | |
| a, b, c = sorted([a,b,c]) | |
| p, q, r = (n//a)+1, (n//b)+1, (n//c)+1 | |
| maximum = -1 | |
| for i in range(r): | |
| for j in range(q): | |
| for k in range(p): | |
| total = (i*c) + (j*b) + (k*a) | |
| if (total==n): | |
| print(i, c, j,b,k,a) | |
| if total == n and (i+j+k) > maximum: | |
| maximum = i+j+k | |
| print(maximum) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TLE with the test case below. and it's natural
4000 1 2 3
That means the fuc*ing approach should be changed.... 🔢