PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000273. Tam giác có diện tích bằng một (S = 1)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tam giác có diện tích bằng một (S = 1)
S = 1
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given two integers , at least one of which is nonzero, consider the three points , and in the coordinate plane.
Find any integer pair for which the triangle has area exactly , with both coordinates in .
If no such integer pair exists, output -1. Any valid pair is accepted.
Input
One line contains two integers .
Output
Print two integers forming any valid pair, or -1 if none exists.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Example 1
Input
3 5
Output
1 1
Explanation
The determinant is , so the area is .
Example 2
Input
-2 0
Output
0 1
Explanation
The determinant is , so the area is .
Example 3
Input
8752654402832944 -6857065241301125
Output
-1
Explanation
The gcd of the two coordinates does not divide , hence area is impossible.