C. Line

Codeforces
IDCF7C
Time1000ms
Memory256MB
Difficulty
mathnumber theory
English · Original
Chinese · Translation
Formal · Original
A line on the plane is described by an equation _Ax_ + _By_ + _C_ = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out that such points do not exist. ## Input The first line contains three integers _A_, _B_ and _C_ ( - 2·109 ≤ _A_, _B_, _C_ ≤ 2·109) — corresponding coefficients of the line equation. It is guaranteed that _A_2 + _B_2 > 0. ## Output If the required point exists, output its coordinates, otherwise output _\-1_. [samples]
平面上的一条直线由方程 $Ax + By + C = 0$ 描述。你需要找到该直线上任意一个坐标为整数且在 $ - 5·10^{18}$ 到 $5·10^{18}$(含)之间的点,或者确定这样的点不存在。 第一行包含三个整数 $A$、$B$ 和 $C$($ - 2·10^9 ≤ A, B, C ≤ 2·10^9$)——直线方程的对应系数。保证 $A^2 + B^2 > 0$。 如果存在所需的点,请输出其坐标;否则输出 _-1_。 ## Input 第一行包含三个整数 $A$、$B$ 和 $C$($ - 2·10^9 ≤ A, B, C ≤ 2·10^9$)——直线方程的对应系数。保证 $A^2 + B^2 > 0$。 ## Output 如果存在所需的点,请输出其坐标;否则输出 _-1_。 [samples]
**Definitions** Let $ A, B, C \in \mathbb{Z} $ be coefficients of the line equation $ Ax + By + C = 0 $, with $ A^2 + B^2 > 0 $. **Constraints** $ -2 \cdot 10^9 \leq A, B, C \leq 2 \cdot 10^9 $ **Objective** Find integers $ x, y \in \mathbb{Z} $ such that: $$ Ax + By + C = 0 \quad \text{and} \quad -5 \cdot 10^{18} \leq x, y \leq 5 \cdot 10^{18} $$ If no such integers exist, output $-1$.
Samples
Input #1
2 5 3
Output #1
6 -3
API Response (JSON)
{
  "problem": {
    "name": "C. Line",
    "description": {
      "content": "A line on the plane is described by an equation _Ax_ + _By_ + _C_ = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF7C"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A line on the plane is described by an equation _Ax_ + _By_ + _C_ = 0. You are to find any point on this line, whose coordinates are integer numbers from  - 5·1018 to 5·1018 inclusive, or to find out ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "平面上的一条直线由方程 $Ax + By + C = 0$ 描述。你需要找到该直线上任意一个坐标为整数且在 $ - 5·10^{18}$ 到 $5·10^{18}$(含)之间的点,或者确定这样的点不存在。\n\n第一行包含三个整数 $A$、$B$ 和 $C$($ - 2·10^9 ≤ A, B, C ≤ 2·10^9$)——直线方程的对应系数。保证 $A^2 + B^2 > 0$。\n\n如果存在所需的点...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ A, B, C \\in \\mathbb{Z} $ be coefficients of the line equation $ Ax + By + C = 0 $, with $ A^2 + B^2 > 0 $.\n\n**Constraints**  \n$ -2 \\cdot 10^9 \\leq A, B, C \\leq 2 \\cdot 10^9 $\n\n...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments