Skip to main content
Back to problems
Codeforces
Easy
Math
Number Theory
Simulation
Help Vasilisa the Wise 2

Find a pair of integers that satisfies simple arithmetic conditions around a given sum and difference.

Acceptance 0%
Problem Statement

Problem

You are given three integers xx, yy, and kk.

Find any pair of integers (a,b)(a, b) such that:

  • a+b=xa + b = x,
  • ab=y|a - b| = y,
  • and both aa and bb are divisible by kk.

If such a pair exists, print it in any order. Otherwise, report that it is impossible.

This is a small constructive arithmetic task: you only need to determine whether the conditions can be satisfied and, if so, output one valid pair.

Input Format

The input contains three integers xx, yy, and kk.

Output Format

If a valid pair exists, output two integers aa and bb separated by a space. Otherwise, output -1.

Constraints

  • The values are integers.
  • You only need to produce one valid pair if it exists.
  • If no pair satisfies all conditions, output -1.
Examples
Sample cases returned by the problem API.

Example 1

Input

10 2 2

Output

6 4

Explanation

The pair $6 and \4 sums to \10, their difference is \2, and both are divisible by \2$.

Example 2

Input

10 3 2

Output

-1

Explanation

No integers can have sum $10 and absolute difference \3 while both being divisible by \2$.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.