Yo`nalishlar
Hozirda online

Statistika

Masalalar soni: 909

Foydalanuvchilar soni: 8820

Jo'natishlar soni: 714406

Muhokama yozuvlari: 4541

Yangiliklar soni: 97

Yangiliklar izohlari: 1174


So'ngi izohlar

461. The number of ones
Vaqt limiti: 1 sekund
Xotira limiti: 64 MB

In arithmetic expression you are allowed to use the number 1, operations of addition, multiplication and parenthesis. What is the minimum number of ones you need to obtain the positive integer n?

Input:   One number n (1n5000).

Output:  The required number of ones.

Input

Output

1

7
6

2

5
5

Example tip: (1 + 1 + 1) * (1 + 1) + 1 = 7

 

 

Tayyorladi: Bahrom Sultonov
Mening urinishlarim(0) Muhokama (7) Jo'natish Eng yaxshi yechimlar Barcha muvaffaqiyatli urinishlar(61) Barcha urinishlar(305)