ABC125C - GCD on Blackboard
Problem summary
There is numbers .
You can change a number between and or do nothing.
Calculate maximum GCD of N numbers after rewriting.
Constraints
・Time limit: 2 sec
・Memory limit: 1024 MB
・Each input is an integer number.
・
・
Answer
You should calculate maximum GCD of N-1 numbers which have N choices.
blute-force
You can remove and simulate. This solution is
optimize
Prepare two sequences and such that
and calculate
.
This solution takes