P2134 Hundred-Day Journey
Background
> What matters is not where to go, but being with you. — Xiaohong
For Xiaoming and Xiaohong, $2014$ year $7$ month $29$ day is a beautiful day. This day is the $100$-day anniversary of their acquaintance.
(Xiaoming: Xiaohong, thank you for your silent support during the $2$ major exams and your companionship over $100$ days and nights; thank you for lighting up my $100$ beautiful days and leaving me countless wonderful memories... On this beautiful day, I plan to take you on a trip.)
Description
Xiaoming and Xiaohong have $n$ days of vacation left, and Xiaoming can plan the trip. If they travel for $x$ consecutive days, Xiaoming needs to spend $p \times x \times x$ yuan. If they do not travel for $x$ consecutive days, Xiaoming needs to treat Xiaohong to meals, costing $q \times x$ yuan ($p, q$ are constants given in the input).
Please help Xiaoming write a program to compute the minimum total amount he needs to spend during the vacation.
Input Format
The input contains a single line with three space-separated positive integers $n, p, q$.
Output Format
Output one line with a single positive integer, representing the minimum amount of money Xiaoming needs to spend.
Explanation/Hint
#### Constraints
- For $20\%$ of the testdata, $1 \le n \le 20$.
- For $90\%$ of the testdata, $1 \le n \le 10^3$, $1 \le p \le 2 \times 10^3$, $1 \le q \le 10^4$.
- For $100\%$ of the testdata, $1 \le n \le 2 \times 10^5$, $1 \le p \le q \le 10^4$.
Translated by ChatGPT 5