Math Teacher's Worry (Easy)
Time limit1sMemory limit1024 MB
For a given n, factor n x^2 + (n+1)x - (n+2) over the integers and print the coefficients, or print -1 if no factorization exists.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
This problem is a subproblem of Math Teacher's Worry (Hard), and you can solve it by submitting the correct code for Math Teacher's Worry (Hard).
Teacher Cha Hyeong-jun, as usual, was puzzling over an interesting problem. He came up with a task: factor the quadratic over the integers, where is a positive integer.
He could work out small values of by hand, but the problem became harder as grew.
So the teacher gave the problem to Do-hoon, who is not strong at math but follows instructions and writes code. However, Do-hoon has only copied and pasted code that ChatGPT gave him, and he can barely print "Hello World!". So he asked ChatGPT to write the code, as usual.
The internet went down while he was waiting for the answer.

The screen shows the moment the internet cut out while Do-hoon was asking ChatGPT to write a program.
Help Do-hoon write a program that factors over the integers.
Input
The first line contains a positive integer .
Output
If the quadratic cannot be factored over the integers for the given , print -1. Otherwise, print four integers , , , and separated by spaces. These four integers mean . If there are several valid pairs, print any of them.
Constraints
.