UVa 10963 - The Swallowing Ground

Contents

  1. 1. Problem
  2. 2. Solution
  3. 3. Code

Problem

中文網址

Solution

直接看每一行上下相差的是否都一樣。

Code

UVa 10963
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<cstdio>

int main()
{
int Case;
scanf("%d", &Case);
while (Case--)
{
int n, diff = 0, top, bottom;
scanf("%d", &n);
while (n--)
{
scanf("%d%d", &top, &bottom);
if (diff != -1)
{
if (!diff)
diff = top - bottom;
else if (diff != top - bottom)
diff = -1;
}
}

puts(diff == -1 ? "no" : "yes");
if (Case)
putchar('\n');
}
return 0;
}