版本1和3间的区别 (跳过第2版)
于2006-03-11 16:18:14修订的的版本1
大小: 1414
编辑: czk
备注:
于2008-02-23 15:34:19修订的的版本3
大小: 1490
编辑: localhost
备注: converted to 1.6 markup
删除的内容标记成这样。 加入的内容标记成这样。
行号 1: 行号 1:
## page was renamed from 程序设计练习13——zju2305——C Looooops

C Looooops

Time limit: 1 Seconds

Memory limit: 32768K

A Compiler Mystery: We are given a C-language style for loop of type

   1 for (variable = A; variable != B; variable += C)
   2    statement;

I.e., a loop which starts by setting variable to value A and while variable is not equal to B, repeats statement followed by increasing the variable by C. We want to know how many times does the statement get executed for particular values of A, B and C, assuming that all arithmetics is calculated in a k-bit unsigned integer type (with values 0 <= x < 2k) modulo 2k.

1. Input

The input consists of several instances. Each instance is described by a single line with four integers A, B, C, k separated by a single space. The integer k (1 <= k <= 32) is the number of bits of the control variable of the loop and A, B, C (0 <= A, B, C < 2k) are the parameters of the loop. The input is finished by a line containing four zeros.

2. Output

The output consists of several lines corresponding to the instances on the input. The i-th line contains either the number of executions of the statement in the i-th instance (a single integer number) or the word FOREVER if the loop does not terminate.

3. Sample Input

{{{3 3 2 16 3 7 2 16 7 3 2 16 3 4 2 16 0 0 0 0}}}

4. Sample Output

zju2305 (2008-02-23 15:34:19由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.