Examples [code] [code] ----- [code] [code] ----- [code] [code]
- User
Examples
input1 1 2output0 1 1
input3 4 5output1 3 2
input4 1 1outputImpossible Assistant
1 1 2
0 1 1
3 4 5
1 3 2
4 1 1
Impossible
First, I need to understand what's being asked: ## Examples
1 1 2
0 1 1
3 4 5
1 3 2
4 1 1
Impossible
Key values given: 1, 1, 2, 0, 1, 1, 3, 4
Working through the calculation: Problem Analysis
Looking at these examples, I need to find the relationship between input (a, b, c) and output (x, y, z). Finding the Pattern
Let me verify with the given examples:
Example 1: Input: 1, 1, 2 → Output: 0, 1, 1 Example 2: Input: 3, 4, 5 → Output: 1, 3, 2
Let me hypothesize that x, y, z satisfy:
Verification for Example 1:
Verification for Example 2:
Solving the System
Given:
Adding all three: 2(x + y + z) = a + b + c
Therefore: x + y + z = (a + b + c)/2
Solving for each variable:
Conditions for Validity
For x, y, z to be non-negative integers:
Verifying "Impossible" Case (Example 3)
Input: 4, 1, 1
Check: b + c = 1 + 1 = 2 < a = 4
This violates condition 3, so y = (1+1-4)/2 = -1 < 0 → Impossible ✓
Solution Code
a, b, c = map(int, input().split())
Calculate x, y, z
x = (a + b - c) // 2
y = (b + c - a) // 2
z = (a + c - b) // 2
Check for validity
if (a + b + c) % 2 != 0 or x < 0 or y < 0 or z < 0:
print("Impossible")
else:
print(x, y, z)
Verification Table
| Input | x | y | z | Checks | Output | 1, 1, 2 | (1+1-2)/2=0 | (1+2-1)/2=1 | (1+2-1)/2=1 | all ≥ 0, sum=4 even | 0 1 1 ✓ | | 3, 4, 5 | (3+4-5)/2=1 | (4+5-3)/2=3 | (3+5-4)/2=2 | all ≥ 0, sum=12 even | 1 3 2 ✓ | | 4, 1, 1 | (4+1-1)/2=2 | (1+1-4)/2=-1 | (4+1-1)/2=2 | y < 0 | Impossible ✓ |
This gives us the final answer: a
Looking at these examples, I need to find the relationship between input (a, b, c) and output (x, y, z).
Let me verify with the given examples:
Example 1: Input: 1, 1, 2 → Output: 0, 1, 1 Example 2: Input: 3, 4, 5 → Output: 1, 3, 2
Let me hypothesize that x, y, z satisfy:
Verification for Example 1:
Verification for Example 2:
Given:
Adding all three: 2(x + y + z) = a + b + c
Therefore: x + y + z = (a + b + c)/2
Solving for each variable:
For x, y, z to be non-negative integers:
Input: 4, 1, 1
Check: b + c = 1 + 1 = 2 < a = 4
This violates condition 3, so y = (1+1-4)/2 = -1 < 0 → Impossible ✓
a, b, c = map(int, input().split())
# Calculate x, y, z
x = (a + b - c) // 2
y = (b + c - a) // 2
z = (a + c - b) // 2
# Check for validity
if (a + b + c) % 2 != 0 or x < 0 or y < 0 or z < 0:
print("Impossible")
else:
print(x, y, z)
| Input | x | y | z | Checks | Output |
|---|---|---|---|---|---|
| 1, 1, 2 | (1+1-2)/2=0 | (1+2-1)/2=1 | (1+2-1)/2=1 | all ≥ 0, sum=4 even | 0 1 1 ✓ |
| 3, 4, 5 | (3+4-5)/2=1 | (4+5-3)/2=3 | (3+5-4)/2=2 | all ≥ 0, sum=12 even | 1 3 2 ✓ |
| 4, 1, 1 | (4+1-1)/2=2 | (1+1-4)/2=-1 | (4+1-1)/2=2 | y < 0 | Impossible ✓ |