zoukankan      html  css  js  c++  java
  • ZOJ 1081 Points Within

    Points Within

    Time Limit: 2 Seconds      Memory Limit: 65536 KB

    Statement of the Problem

    Several drawing applications allow us to draw polygons and almost all of them allow us to fill them with some color. The task of filling a polygon reduces to knowing which points are inside it, so programmers have to colour only those points.

    You're expected to write a program which tells us if a given point lies inside a given polygon described by the coordinates of its vertices. You can assume that if a point is in the border of the polygon, then it is in fact inside the polygon.

    Input Format

    The input file may contain several instances of the problem. Each instance consists of: (i) one line containing integers N, 0 < N < 100 and M, respectively the number of vertices of the polygon and the number of points to be tested. (ii) N lines, each containing a pair of integers describing the coordinates of the polygon's vertices; (iii) M lines, each containing a pair of integer coordinates of the points which will be tested for "withinness" in the polygon.

    You may assume that: the vertices are all distinct; consecutive vertices in the input are adjacent in the polygon; the last vertex is adjacent to the first one; and the resulting polygon is simple, that is, every vertex is incident with exactly two edges and two edges only intersect at their common endpoint. The last instance is followed by a line with a 0 (zero).

    Output Format

    For the ith instance in the input, you have to write one line in the output with the phrase "Problem i:", followed by several lines, one for each point tested, in the order they appear in the input. Each of these lines should read "Within" or "Outside", depending on the outcome of the test. The output of two consecutive instances should be separated by a blank line.

    Sample Input

    3 1
    0 0
    0 5
    5 0
    10 2
    3 2
    4 4
    3 1
    1 2
    1 3
    2 2
    0

    Sample Output

    Problem 1:
    Outside

    Problem 2:
    Outside
    Within

    #include <stdio.h>
    #include <math.h>

    double D,M,A,J,jtime, jtimeaccellimit, jtimespeedlimit, jtimedistlimit,
    atime, dist, delta, a, b, c, r;

    double cubrt(double x) {
    return (exp(log(x)/3));
    }

    main(){
    while (4 == scanf("%lf%lf%lf%lf",&D,&M,&A,&J)) {
    jtimeaccellimit = A/J;
    jtimespeedlimit = sqrt(M/J);
    jtimedistlimit = cubrt(D/2/J);
    jtime = jtimeaccellimit;
    if (jtimespeedlimit < jtime) jtime = jtimespeedlimit;
    if (jtimedistlimit < jtime) jtime = jtimedistlimit;
    atime = (M - J*pow(jtime,2))/A;
    a = 0.5*A;
    b = A*jtime + 0.5*J*pow(jtime,2);
    c = J * pow(jtime,3) - D/2;
    r = (-b + sqrt(b*b - 4*a*c))/2/a;
    if (r < atime) atime = r;
    dist = J * pow(jtime,3)
    + 0.5*J*pow(jtime,2)*atime + 0.5*A * pow(atime,2)
    + A * atime*jtime;
    printf("%0.1lf\n",4*jtime+2*atime+2*(D/2-dist)/M);
    }
    }
  • 相关阅读:
    索引跳跃式扫描(INDEX SKIP SCAN)
    Oracle参数Arraysize设置对于逻辑读的影响分析
    Oracle的SQL优化思路
    通过SID查找历史执行的SQL语句
    expdp/impdp数据泵分区表导入太慢了。添加不检查元数据参数提高效率:ACCESS_METHOD=DIRECT_PATH
    Oracle不能并行直接添加主键的方法:先建唯一索引后建主键
    ORA-20011 问题处理
    安装grid时找不到ASM共享磁盘
    jmeter-测试计划
    jmeter解压后启动jmeter.bat报错:Not able to find java executable or version
  • 原文地址:https://www.cnblogs.com/kuangbin/p/2250031.html
Copyright © 2011-2022 走看看