2 shunfurh shunfurh 于 2017.09.16 21:48 提问

Problem H: Hills

Little Billy likes drawing with chalks of all colors. As a child of his age, all he can do is to draw straight lines. Today he has been told that hills are of the shape of triangles, and he brought out a lot of his works and tried to identify as many hills as he could. Being one of his best friends, you gladly joined his effort. However after working for a while you are desperate to find the huge number of sketches he has produced. You suggested this alternative plan �C to code up a program for him.

This sample figure only contains a single "hill"
Keep in mind that in Billy's pictures all the lines are connected, and no line will have an end point right on another line. We would only count the hills that are not cut by other lines.

Input Description

Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <= 10) which is the number of test cases. T test cases follow, each preceded by a single blank line.

Each test case starts with an integer N (1 < N <= 500), which is the number of lines on the picture. The next N lines contain a line segment's two end points. The coordinates are all integers (-10,000 < x, y < 10,000).

Output Description

Results should be directed to standard output. Start each case with "Case #:" on a single line, where # is the case number starting from 1. Two consecutive cases should be separated by a single blank line. No blank line should be produced after the last test case.

For each test case, print the number of hills on a single line.

Sample Input

3

3
-1 0 3 0
0 -1 0 3
-1 3 3 -1

4
-3 0 3 0
-3 -1 1 3
3 -1 -1 3
0 3 0 -1

6
-3 -2 3 -2
-2 -3 -2 3
-3 2 3 2
2 -3 2 3
-3 -3 3 3
1 -1 -1 1
Sample Output

Case 1:
1

Case 2:
2

Case 3:
0

1个回答

caozhy
caozhy   Ds   Rxr 2017.09.30 21:39
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
GREEN.HILLS.SOFTWARE.MULTI.FOR.MIPS.V4.0.7 破解文件
GREEN.HILLS.SOFTWARE.MULTI.FOR.MIPS.V4.0.7 破解文件 Green Hills C/C++ Compilers fully conform to ANSI/ISO industry standards, and include optional enforcement of MISRA C programming guidelines. A complete implementation of the C, C++, EC++, Ada 95 and FORTRAN libraries are included in compiler distributions. Full featured start-up code and libraries include automatic copy of data from ROM to RAM and system call emulation. Green Hills C/C++ Optimizing Compilers provide userselectable optimization options that trade-off code size vs. execution efficiency. In particular, for the MIPS16e and MIPS16 ASEs, benchmark tests have proven the effectiveness of the Green Hills Compilers in producing the smallest executable file from a given source base.
GreenHills MULTI: Getting Started
MULTI is a complete Integrated Development Environment (IDE) designed especially for embedded systems engineers to assist them in analyzing, editing, compiling, optimizing, and debugging embedded applications.
USACO-Section 1.3 Ski Course Design(枚举)
思路:数据很小,直接枚举山的最高高度即可,对于山的最高高度i,若i-h[j]>17,则将h[j]的高度调整为i-17;若h[j]>i,则将h[j]的高度调整为i;求出所有最高高度的方案调整费用的最小值。
Problem H: 线性表的基本操作
Problem H: 线性表的基本操作 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 481  Solved: 265 [Submit][Status][Web Board] Description 线性表是一类重要的且基础的数据结构。请定义MyList类,来模拟针对线性表的插入、删除等操作: 1. 数据成员int *eleme
Green Hills MPC5744P Qorivva MCUs入门指南
Green Hills MPC5744P Qorivva MCUs入门指南.超级详细的green hills的使用资料
Problem H: STL——字符串排序
Problem H: STL——字符串排序 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 2872  Solved: 1234 [Submit][Status][Web Board] Description     对N个字符串排序。     0 Input     第一行读入N。     后面N行,每行一个字
Echo and Narcissus in Greek Mythology
                             Narci,comes from a myth of GreeceEcho was a beautiful nymph, fond of the woods and hills, where she devoted herself to woodland sports. She was a favorite of Artemis, an
HDU2601,An easy problem
该题确实在个简单的问题,因为可能形式很简单,但它又不是那么的简单。 如果这个题选择有两个for循环来写的话,那毫无疑问将超时,所以需要仔细分析一下,可以看出,N=i*j+i+j可以变形为:N+1=( i+1)*( j+1),且由 0<i<=j,可知:1<( i+1)<=( j+1),所以就以(i+1)为基准来进行循环,所以只需要单层循环即可。 再有,由于要考虑它的重复性,所以循环只需要进行到sqrt(N+1)即可,往后再循环的必重复。本题 i 要从1开始,所以 i+1 就要从2开始循环,一直到sqrt(N+
Andrew Stankevich Contest 38 , J-Jackpot
J-Jackpot
Problem H: 稀疏矩阵的表示和运算 SDUSTOJ
本来想用 vector ,试了下不好实现,换用 node 的数组 重载运算#include<iostream> #include<cstdio> #include<vector> #include<algorithm> #include<set> using namespace std; const int maxn = 10000;struct node { int r, c, v; }