题解 CF1206B 【Make Product Equal One】

topic:

CodeForces link

Luogu link

Ideas:

This is a one title

We wish all the numbers are seen as \ (1 \) (take appropriate cost, such as: \ (6 \) cost is \ (6--1 = 5 \) , take the variable \ (ans \) Record) .

If this is a negative number, take a variable \ (negative \) recorded a negative number.

For negative numbers, when there are an even number of them have become \ (- 1 \) does not matter, because even number \ (- 1 \) multiplied by the final answer is \ (1 \) , so when there is an even number when a negative answer to \ (ANS - negative × 2 \) (multiplied by \ (2 \) ,)

The final answer is \ (ans - (negative - negative % 2) \)

Guess you like

Origin www.cnblogs.com/GJY-JURUO/p/11391495.html