Update X with Operations
Python
Easy
2 views
Problem Description
Read two integers x and y. Do these updates in order: x=x+y, y=y+1, x=x-y. Output final x and y.
Input Format
One line: x y.
Output Format
One line: x y after updates.
Official Solution
import sys
s=sys.stdin.read().strip().split()
if not s: sys.exit(0)
x=int(s[0]); y=int(s[1])
x=x+y
y=y+1
x=x-y
sys.stdout.write(f"{x} {y}")
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!