Hangzhou Electric 2540--occlusion judgment (maths problem)

Source: Internet
Author: User

Occlusion Judgment

Time limit:10000/3000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 910 Accepted Submission (s): 295

Problem description There is a row of pillars along the east-west alignment of the square, and the sun shines from the east with a certain inclination (parallel light). Some pillars may be completely obscured by the shadow of the tall pillar in the east of him. Now the problem you have to solve is to find out how many pillars are not completely obscured.
Suppose each stone pillar is a fine rod and is placed perpendicular to the ground.

Input inputs contain multiple sets of data. The first row of each set of data is an integer N (0<n<=100000) that represents the number of columns. N=0 represents the end of the input. Then there are n rows, each line being two integers, giving each pillar a horizontal position x and a height of H (the greater the X, the farther west, the 0<=x<=10000000,0

Output contains the number of rows for each set of data.

Sample INPUT40 33 12 21 11/10

Sample Output2 Tip: Enter a lot of data, please use scanf instead of CIN.

SOURCEUESTC 6th Programming Contest Online

Recommendlcy | We have carefully selected several similar problems for you:2537 2539 2538 2546 2545 violence to judge. The height of the front bar minus the height of the current bar and minus the middle interval.
#include <cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespacestd;Const intN =100001;structposi{Doublex, y;} Num[n];BOOLCMP (posi x, posi y) {returnx.x <y.x; }intMain () {intT;  while(~SCANF ("%d", &t), T) { for(inti =0; i < T; i++) scanf ("%LF%LF", &num[i].x, &num[i].y); DoubleTana, TANB; scanf ("%LF/%LF", &tana, &tanb); Sort (num, num+T, CMP);//Sort the order by position.         DoubleMax = num[0].y; intsum =0;  for(inti =1; i < T; i++){            if(Max-num[i].y-(num[i].x-num[i-1].x) *tana/tanb >=0){//Update max value and calculate the number of blocked bars;sum++; Max= Max-(num[i].x-num[i-1].x) *tana/tanb; }            ElseMax=num[i].y; } printf ("%d\n", Tsum); }    return 0;}

Hangzhou Electric 2540--occlusion judgment (maths problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.