Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
MELE2 - ELEVATOR II |
English | Vietnamese |
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ée 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 doesn’t 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.
Input
The first line of the input file contains one integer h — the height of the skyscraper (1 ≤ h ≤ 10^18). The second line contains three integers a, b and c — the parameters of the buttons (1 ≤ a, b, c ≤ 100000)
Output
Output one integer number — the number of floors that are reachable from the first floor.
Example
Input 1: 15 4 7 9 Output 1: 9
Input 2: 500000 160 96 111 Output 2: 498167
Input 3: 987654321987654321 99995 99997 99999 Output 3: 987654319487854318
Được gửi lên bởi: | psetter |
Ngày: | 2009-02-26 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: C99 ERL GOSU JS-RHINO PERL6 PYPY RUST SED |
Nguồn bài: | NEERC 2007–2008 |
hide comments
2020-03-12 03:26:08
bài hay |
|
2019-08-31 08:56:19
hình như test sai |
|
2019-04-25 08:07:11
chục đấm AC =)) sợ trào mảng nên để LLONG_MAX/100 :V giới hạn to vào nha :D LLONG_MAX/2 là ngon r =(( |
|
2017-11-09 10:51:27
đọc đề nha đừng nhìn ví dụ :))))))))) |
|
2017-11-08 15:15:42
hào sạch |
|
2009-06-13 16:14:59 Mệt
Nhờ PS xem hộ bài em sai test nào với ạ. Em làm mãi mà vẫn wa :(( |