Ints
SRM 535 · 2012-01-31 · by wrong
Problem Statement
Fox Jiro and Eel Saburo are good friends. One day Jiro received a letter from Saburo. The letter contains four integers representing an encrypted message. Please help Jiro to decrypt the message.
You are given four
- AminusB = A - B
- BminusC = B - C
- AplusB = A + B
- BplusC = B + C
There is always at most one triplet of integers A, B, C that satisfies all four equalities.
If it exists, return a
Constraints
- AminusB will be between -30 and 30, inclusive.
- BminusC will be between -30 and 30, inclusive.
- AplusB will be between -30 and 30, inclusive.
- BplusC will be between -30 and 30. inclusive.
1
-2
3
4
Returns: {2, 1, 3 }
A - B = 2 - 1 = 1 B - C = 1 - 3 = -2 A + B = 2 + 1 = 3 B + C = 1 + 3 = 4
0
0
5
5
Returns: { }
A = B = C = 2.5 satisfy all four equalities, but A, B, and C must all be integers.
10
-23
-10
3
Returns: {0, -10, 13 }
A, B, and C may be negative or zero.
-27
14
13
22
Returns: { }
30
30
30
-30
Returns: {30, 0, -30 }
Submissions are judged against all 109 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FoxAndIntegers with a public method vector<int> get(int AminusB, int BminusC, int AplusB, int BplusC) · 109 test cases · 2 s / 256 MB per case