TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

The formula for converting a Gahrenheit temperature G to the corresponding Delsius temperature D is D=(G-A)*B/C. An integer Gahrenheit temperature is converted to Delsius and rounded to the nearest integer (rounding up to break the tie); the resulting integer Delsius temperature is converted back to Gahrenheit and rounded to the nearest integer (rounding up to break the tie too). For how many Gahrenheit temperature T with A <= T <= N does the original temperature equal the final temperature?
Note: the given equation may not be G=(D-32)*5/9.

Input Format

There are multiple test cases.
Each test case consists of a single line containing the four intergers-A, B, C and N, listed in this order.
Input is terminated by EOF (End of File).


1 <= A,B,C <= 10000. A <= N <= 1018

Output Format

For each test case, output one line - the answer.

Sample Input 1

32 5 9 1000

Sample Output 1

539

Hints

Problem Source

Migrated from old NTUJ.

CodeCraft 2010

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 200