Editorial for HSG THPT Hải Phòng 2023 - Bài 4


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Nhận xét số ~1~ : Nếu ~k~ là số chẵn thì đáp án luôn luôn bằng ~0~.

Nhận xét số ~2~ : ~a_u + a_v = k~, suy ra ~a_v~ = ~k~ - ~a_u~. Vậy nếu ta lần lượt thử các giá trị ~a_u~ thì bài toán trở thành tìm kiếm xem trong mảng có tồn tại phần tử ~a_v~ = ~k~ - ~a_u~ mình đang xét tới hay không ?

Dễ dàng thực hiện bằng map hoặc set.


Comments

Please read the guidelines before commenting.


There are no comments at the moment.