Hozirda online


Masalalar soni: 909

Foydalanuvchilar soni: 8824

Jo'natishlar soni: 714622

Muhokama yozuvlari: 4541

Yangiliklar soni: 98

Yangiliklar izohlari: 1177

So'ngi izohlar

773. Elevator
Vaqt limiti: 1 sekund
Xotira limiti: 64 MB

Edward works as an engineer for Non-trivial Elevators: Engineering, Research and Construction (NEERC). His new task is to design a brand new elevator for a skyscraper with h floors.

Edward has an id´ee fixe: he thinks that four buttons are enough to control the movement of the elevator.

His last proposal suggests the following four buttons:

Move a floors up.

Move b floors up.

Move c floors up.

Return to the first floor.

Initially, the elevator is on the first floor. A passenger uses the first three buttons to reach the floor she needs. If a passenger tries to move a, b or c floors up and there is no such floor (she attempts to move higher than the h-th floor), the elevator doesnt move.

To prove his plan worthy, Edward wants to know how many floors are actually accessible from the first floor via his elevator. Help him calculate this number.


The first line of the input file contains one integer h the height of the skyscraper (1 ≤ h ≤ 500 000).

The second line contains three integers a, b and c the parameters of the buttons (1 ≤ a, b, c ≤ 100 000).


Output one integer number the number of floors that are reachable from the first floor.






4 7 9



Tayyorladi: Azat Yusupov
Text from: Uzbekistan subregional
Mening urinishlarim(0) Muhokama (0) Jo'natish Eng yaxshi yechimlar Barcha muvaffaqiyatli urinishlar(36) Barcha urinishlar(115)