A. Restoring Numbers

Codeforces
IDCF10175A
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Pavel had two positive integers a and b. He found their sum s and greatest common divisor g, and forgot a and b after that. Help him to restore the original numbers. A single line contains two integers s and g (1 ≤ s ≤ 109, 1 ≤ g ≤ 109) — sum and greatest common divisor of the numbers a and b. If Pavel made a mistake and there are no such numbers a and b, output a single number  - 1. Otherwise, output two positive integers a and b on a single line, separated by a space. If there are multiple possible solutions, output any of them. ## Input A single line contains two integers s and g (1 ≤ s ≤ 109, 1 ≤ g ≤ 109) — sum and greatest common divisor of the numbers a and b. ## Output If Pavel made a mistake and there are no such numbers a and b, output a single number  - 1.Otherwise, output two positive integers a and b on a single line, separated by a space. If there are multiple possible solutions, output any of them. [samples]
**Definitions** Let $ s, g \in \mathbb{Z}^+ $ be given, with $ 1 \leq s, g \leq 10^9 $. **Constraints** Find positive integers $ a, b \in \mathbb{Z}^+ $ such that: 1. $ a + b = s $ 2. $ \gcd(a, b) = g $ **Objective** If such $ a, b $ exist, output any pair $ (a, b) $. Otherwise, output $ -1 $.
API Response (JSON)
{
  "problem": {
    "name": "A. Restoring Numbers",
    "description": {
      "content": "Pavel had two positive integers a and b. He found their sum s and greatest common divisor g, and forgot a and b after that. Help him to restore the original numbers. A single line contains two intege",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10175A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Pavel had two positive integers a and b. He found their sum s and greatest common divisor g, and forgot a and b after that. Help him to restore the original numbers.\n\nA single line contains two intege...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ s, g \\in \\mathbb{Z}^+ $ be given, with $ 1 \\leq s, g \\leq 10^9 $.  \n\n**Constraints**  \nFind positive integers $ a, b \\in \\mathbb{Z}^+ $ such that:  \n1. $ a + b = s $  \n2. $ \\gc...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments