BNU Playing Field
来源:互联网 发布:二战中国功劳排名 知乎 编辑:程序博客网 时间:2024/06/05 03:20
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
const int M=50010;
struct node
{
double x,y;
}p[M];
double det(double a,double b,double c,double d)
{
return a*d-b*c;
}
double area(node a,node b,node c)
{
return 0.5*fabs(det(c.x-a.x,c.y-a.y,c.x-b.x,c.y-b.y));
}
double sum[M];
int main()
{
int n,m;
bool you=false;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n==0&&m==0)break;
if(you)puts("");
you=true;
for(int i=0;i<n;i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
}
memset(sum,0,sizeof(sum));
for(int i=2;i<n;i++)
{
sum[i]=sum[i-1]+area(p[0],p[i-1],p[i]);
}
int a,b;
while(m--)
{
scanf("%d%d",&a,&b);
double sum1=sum[b]-sum[a]-area(p[0],p[a],p[b]);
double sum2=sum[n-1]-sum1;
if(sum2<sum1)
sum1=sum2;
printf("%.1lf\n",sum1);
}
}
return 0;
}
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
const int M=50010;
struct node
{
double x,y;
}p[M];
double det(double a,double b,double c,double d)
{
return a*d-b*c;
}
double area(node a,node b,node c)
{
return 0.5*fabs(det(c.x-a.x,c.y-a.y,c.x-b.x,c.y-b.y));
}
double sum[M];
int main()
{
int n,m;
bool you=false;
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n==0&&m==0)break;
if(you)puts("");
you=true;
for(int i=0;i<n;i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
}
memset(sum,0,sizeof(sum));
for(int i=2;i<n;i++)
{
sum[i]=sum[i-1]+area(p[0],p[i-1],p[i]);
}
int a,b;
while(m--)
{
scanf("%d%d",&a,&b);
double sum1=sum[b]-sum[a]-area(p[0],p[a],p[b]);
double sum2=sum[n-1]-sum1;
if(sum2<sum1)
sum1=sum2;
printf("%.1lf\n",sum1);
}
}
return 0;
}
- BNU Playing Field
- BNU - Playing Field 想法题。
- BNU
- Field
- Playing Cubes
- BNU 1042
- BNU 12883
- BNU 16225
- bnu 4067
- BNU 1065
- bnu-44582
- BNU ---- 收成
- bnu 45517
- bnu 45519
- bnu 45518
- BNU 51645
- BNU 49102
- BNU 49103
- Fragment_学习3
- 10种提高WordPress访问速度的方法
- Class.forName() 和 ClassLoader.loadClass()的区别?
- LeetCode: Maximal Rectangle
- wp-config.php文件小功能分享
- BNU Playing Field
- 用Munin监控Linux服务器性能
- android LinearLayout类研究
- 国庆长假结束了
- oracle 存储过程的基本语法
- 关于Repeater控件的使用
- 【转载】fatal error C1010: unexpected end of file while looking for precompiled header directive
- ubuntu上hadoop配置
- vs中的小技巧