PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000015. Làm tích chia hết cho lũy thừa hai (Divisibility by 2^n)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Làm tích chia hết cho lũy thừa hai (Divisibility by 2^n)
Divisibility by 2^n
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers, make their product divisible by . An operation chooses index and replaces with . Each index may be used at most once. Find the minimum number of operations or -1 if impossible.
Input
First line ; second line integers .
Output
Print the minimum operations or -1.
Subtasks
- Subtask 1 (20 points): ;
- Subtask 2 (30 points): ;
- Subtask 3 (50 points): ;
Examples
Input
4
1 2 3 4
Output
1
Explanation
The initial product contains three factors of . One operation at index or increases that count to at least four.