#Q220. 「一本通 6.4 练习 4」C Looooops
「一本通 6.4 练习 4」C Looooops
Description
Original source: CTU Open 2004
For the C language loop statement:
for (variable = A; variable != B; variable += C)
statement;
determine how many times the loop will execute before terminating in a -bit storage system. If it terminates within a finite number of iterations, output the loop count. Otherwise, output that it runs forever.
Input Format
Multiple test cases, each consisting of four integers on a single line. Here, denotes the -bit storage system.
The input ends with 0 0 0 0.
Output Format
If the loop terminates within a finite number of iterations, output the loop count. Otherwise, output FOREVER.
Sample 1
3 3 2 16
3 7 2 16
7 3 2 16
3 4 2 16
0 0 0 0
0
2
32766
FOREVER
Data Range and Hint
For all data, , .