Logulo P1011 Station Label: Qaq unknown 50 minutes

Source: Internet
Author: User
Title Description

The train departs from the starting point (called the 1th Station), the number of passengers arriving at the start of the station is a, then to the 2nd stop, and at the 2nd stop, the number of people on and off the bus is the same, so the number of passengers on the 2nd station (i.e. before arriving at the 3rd station) remains a. From the 3rd station (including the 3rd station), the number of people have a certain regularity: the number of passengers are the first two stations on the number of passengers, and the number of alight is equal to the number of passengers on the last station, until the terminus of the previous station (N-1 station), are satisfied with this law. The conditions are as follows: There are n stations, the number of passengers on the bus is a, and the number of the last stop is M (all get off). What is the number of people on the bus when X station is opened?

Input/output format

Input format:

A (<=20), N (<=20), M (<=2000), and X (<=20),

Output format:

The number of people on the bus from X station.

Input and Output Sample input example # #:

5 7 32 4
Sample # # of output:
13
Code

Unknown 50 points

Logulo P1011 Station Label: Qaq unknown 50 minutes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.