Hard Evidence -UVa 11562


Hard Evidence

\epsfbox{p115xx.eps}

The young reporter Janne is planning to take a photo of a secret government installation. He needs to obtain evidence of the many serious crimes against good sense that are being committed there, so as to create a scandal and possibly win a Pulitzer. Unfortunately, the base is surrounded by a high fence with high voltage wires running around. Janne does not want to risk being electrocuted, so he wants to take a photo from outside the fence. He can bring a tripod as high as the fence to take a photo, so if he wants he can stand right beside the fence and take his picture. The secret installation is a convex polygon. The fence has a form of a circle. Of course Janne wants to make a photo with maximal possible detail level.

Consider taking a photo of the base from some point P outside the fence. Let Q be the left-most point of the base when viewed from P , and let R be the right-most point of the base when viewed from P . Then the view angle of the base at P is the angle at P in the triangle formed by the three points P , Q and R .

The detail level of the photo depends on the view angle of the base at the point from which the photo is taken. Therefore he wants to find a point to maximize this angle.

Input

The input file contains several test cases, each of them as described below.

The first line of the input file contains two integer numbers: n and r -- the number of vertices of the polygon and the radius of the fence (3$ \le$n$ \le$200 , 1$ \le$r$ \le$1000 ). The following n lines contain two real numbers each -- the coordinates of the vertices of the polygon listed in counterclockwise order. It is guaranteed that all vertices of the polygon are strictly inside the fence circle, and that the polygon is convex. The center of the fence circle is located at the origin, (0, 0) .

Output

For each test case, write to the output the maximal view angle a for the photo ( 0$ \le$a < 2$ \pi$ ), on a line by itself. Any answer with either absolute or relative error smaller than 10-6 is acceptable.

Sample Input

4 2
-1.0 -1.0
1.0 -1.0
1.0 1.0
-1.0 1.0

Sample Output

1.5707963268


题意:找到最大的能够看到的角度。

思路:先预处理,即找到相邻的两个点的连线与圆的交点的两个点所分别对应的角度,找到所有可能的情况,然后对这两个点进行三分操作,找到最大的角度。

另外预处理的那部分几何不好,所有从网上借鉴的代码,不过剩下的部分是我写的。

AC代码如下:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const double eps=1e-8,pi=3.14159265358979;
double x[210],y[210],start[210],end[210],r;
int n;
void QuadraticEquation(double a, double b, double c, double &res1, double &res2)
{   double d = b * b - 4 * a * c;
    if (d < 0) return ;
    d = sqrt(d);
    res1 = (-b + d) / (2 * a);
    res2 = (-b - d) / (2 * a);
    return ;
}
double solve(double mi,int i,int j)
{ double x1,y1,a,b,c,angle,ans;
  if(j>n)
   j=1;
  x1=r*cos(mi);
  y1=r*sin(mi);
  a=(x1-x[i])*(x1-x[i])+(y1-y[i])*(y1-y[i]);
  b=(x1-x[j])*(x1-x[j])+(y1-y[j])*(y1-y[j]);
  c=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
  angle=(a+b-c)/(2*sqrt(a*b));
  ans=acos(angle);
  return ans;
}
int main()
{ int i,j,k,t;
  double dx,dy,a,b,c,res1,res2,mi,mi1,mi2,val,val1,val2,angle,ans,px1,px2,py1,py2,left,right,st1,end1,st2,end2;
  while(~scanf("%d%lf",&n,&r))
  { ans=0;val=0;angle=0;ans=0;
    for(i=1;i<=n;i++)
     scanf("%lf%lf",&x[i],&y[i]);
    for(i=1;i<=n;i++)
    { j=i+1;
      if(j>n)
       j=1;
       dx = x[j] - x[i], dy = y[j] - y[i];
       c = x[i] * x[i] + y[i] * y[i] - r * r;
       a = dx * dx + dy * dy, b = 2 * (dx * x[i] + dy * y[i]);
       QuadraticEquation(a, b, c, res1, res2);
       px1 = x[i] + res1 * dx, py1 = y[i] + res1 * dy;
       px2 = x[i] + res2 * dx, py2 = y[i] + res2 * dy;
       start[i] = atan2(py2, px2);
       end[i] = atan2(py1, px1);
    }
    for(i=1;i<=n;i++)
    { j=i;
      left=start[i];
      right=end[j];
      if(left>right)
       right+=pi*2;
      while(true)
      { while(left+eps<right)
        { mi=(right-left)/3;
          mi1=left+mi;
          mi2=left+mi*2;
          val1=solve(mi1,i,j+1);
          val2=solve(mi2,i,j+1);
          if(val1>val2)
           right=mi2;
          else
           left=mi1;
        }
        if(val1>angle)
         angle=val1;
        j++;
        if(j>n)
         j=1;
        st1=start[i];
        end1=end[i];
        if(st1>end1)
         end1+=2*pi;
        st2=start[j];
        if(st1<=st2 && st2<=end1)
        { left=st2;
          right=end1;
          continue;
        }
        st2+=2*pi;
        if(st1<=st2 && st2<=end1)
        { left=st2;
          right=end1;
          continue;
        }
        break;
      }
    }
    printf("%.10f\n",angle);
  }
}



资源下载链接为: https://pan.quark.cn/s/9e7ef05254f8 在苹果的生态系统中,IAP(应用内购买)是苹果应用商店(App Store)中应用开发者常采用的一种盈利模式,允许用户在应用内直接购买虚拟商品或服务。苹果为开发者提供了一份详细的人民币(CNY)IAP定价表,这份定价表具有以下特点: 价格分级:定价表由多个价格等级组成,开发者可根据虚拟商品的价值选择相应等级,等级越高,价格越高。例如,低等级可能对应基础功能解锁,高等级则对应高级服务或大量虚拟道具。 税收与分成:苹果会从应用内购买金额中抽取30%作为服务费或佣金,这是苹果生态的固定规则。不过,开发者实际到手的收入会因不同国家和地区的税收政策而有所变化,但定价表中的价格等级本身是固定的,便于开发者统一管理。 多级定价策略:通过设置不同价格等级,开发者可以根据商品或服务的类型与价值进行合理定价,以满足不同消费能力的用户需求,从而最大化应用的总收入。例如,一款游戏可以通过设置不同等级的虚拟货币包,吸引不同付费意愿的玩家。 特殊等级:除了标准等级外,定价表还包含备用等级和特殊等级(如备用等级A、备用等级B等),这些等级可能是为应对特殊情况或促销活动而设置的额外价格点,为开发者提供了更灵活的定价选择。 苹果IAP定价表是开发者设计应用内购机制的重要参考。它不仅为开发者提供了标准的收入分成模型,还允许开发者根据产品特性设定价格等级,以适应市场和满足不同用户需求。同时,开发者在使用定价表时,还需严格遵守苹果的《App Store审查指南》,包括30%的分成政策、使用苹果支付接口、提供清晰的产品描述和定价信息等。苹果对应用内交易有严格规定,以确保交易的透明性和安全性。总之,苹果IAP定价表是开发者在应用内购设计中不可或缺的工具,但开发者也需密切关注苹果政策变化,以确保应用的合规运营和收益最大化。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值