P27877 [洛谷] [Language Monthly Contest 202309] Array and Memory EV
普及-
题目描述

Problem Description

A one-dimensional array is often imagined as a linear sequence, a two-dimensional array as a matrix on a plane, and a three-dimensional array as a cube in space. Since we live in a three-dimensional universe, arrays of higher dimensions are difficult to imagine, but we have reason to believe that an $n$-dimensional array can be imagined as a geometric shape in $n$-dimensional space.

However, no matter how high the dimensionality of the array, the memory space of a computer is always linear.
- In C++, when defining a one-dimensional array $a[N]$, it will start from $a[0]$ and consecutively allocate $N$ variables in continuous memory space, assigned to $a[0], a[1], \cdots, a[N-1]$.

  • A two-dimensional array $a[N][M]$ can be seen as $N$ one-dimensional arrays of size $M$ concatenated together. When defining a two-dimensional array $a[N][M]$ in C++, it will start from $a[0][0]$ and allocate $N \times M$ variables in continuous memory space, first arranging the one-dimensional array $a[0]$, then sequentially arranging the one-dimensional arrays $a[1], a[2], \cdots, a[N-1]$. The arrangement rules are the same as for the one-dimensional array.

  • The same logic applies to arrays of higher dimensions.

It is well known that the index range for a two-dimensional array $a[N][M]$ is $a[0 \sim N-1][0 \sim M-1]$. However, when defining an array $a[2][3]$ and using the index $a[0][4]$, it does not access illegal memory but accesses $a[1][1]$. This is because the array relies on continuous linear memory, and both $a[0][4]$ and $a[1][1]$ point to the fifth variable starting from $a[0][0]$ (including $a[0][0]$), and they point to the same memory address. The same mechanism applies to arrays of higher dimensions.

Now, Xiao F has defined a two-dimensional array $a[N][M]$ and tries to access $a[p][q]$. Please determine if Xiao F will access illegal memory.

Input Format

Input consists of a single line with four non-negative integers, $N, M, p, q$ in sequence.

Output Format

Output a single line with a string:

  • If illegal memory is accessed, output Segmentation fault..
  • If no illegal memory is accessed, output Program ends with return value 0..

Sample Input and Output

Sample Input #1

4 2 2 3

Sample Output #1

Program ends with return value 0.

Sample Input #2

4 2 2 100

Sample Output #2

Segmentation fault.

Notes

  • For $60\%$ of the test cases, $1 \le N, M \le 10^4$, $0 \le p, q \le 10^4$;
  • For $100\%$ of the test cases, $1 \le N, M \le 10^9$, $0 \le p, q \le 10^9$.
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 2 2 3
样例输出
Program ends with return value 0.