poj 1687 Buggy Sat 简单计算几何

暑期集训出的第一道一血 感觉自己萌萌哒……

这道题本身并没有坑点 仅仅是翻译巨坑……

解大腿在做B 安学长在做E 我闲着也没事 就一个词一个词翻译F……

最后感觉……

题干大多数都看不懂……

也都没啥用……

大概呢……

就是给你n个点……

m条回路……

问你哪条回路是最外面的……

总之最后就是让你求哪个回路组成的图形面积最大……

考点就是多边形面积公式……

怕有误差就没加/2……

好像加了也能过吧……

WA了两次 一次是选错点了 一次是第一个点和最后一个点顺序反了……

 1 #include<stdio.h>
 2 #include<string.h>
 3 struct point{
 4     int x,y;
 5 }p[1005];
 6 int area(point a,point b){
 7     return ((a.x*b.y)-(b.x*a.y));
 8 }
 9 int main(){
10     int T;
11     scanf("%d",&T);
12     while(T--){
13         int n;
14         scanf("%d",&n);
15         for(int i=1;i<=n;i++)
16             scanf("%d%d",&p[i].x,&p[i].y);
17         int m,q;
18         int s[1005];
19         int maxn=-1;
20         int flag;
21         scanf("%d",&m);
22         for(int i=1;i<=m;i++){
23             scanf("%d",&q);
24             int now=0;
25             scanf("%d",&s[0]);
26             for(int j=1;j<q;j++){
27                 scanf("%d",&s[j]);
28                 now+=area(p[s[j-1]],p[s[j]]);
29             }
30             now+=area(p[s[q-1]],p[s[0]]);
31             if(now>maxn){
32                 maxn=now;
33                 flag=i;
34             }
35         }
36         printf("%d\n",flag);
37     }
38     return 0;
39 }
时间: 2024-08-10 01:30:35

poj 1687 Buggy Sat 简单计算几何的相关文章

POJ 1556 The Doors(简单计算几何+最短路)

●赘述题目 10*10的房间内,有竖着的一些墙(不超过18个).问从点(0,5)到(10,5)的最短路. 按照输入样例,输入的连续5个数,x,y1,y2,y3,y4,表示(x,0--y1),(x,y2--y3),(x,y4--10)是墙壁. ●题解 方法:建图(用到简单计算几何)+最短路 ○记录下每个端点. ○包含起点,终点,以及每个墙的可以走的端点,如下图: ○然后枚举点,尝试两两组合连(线段)边,若该线不会撞在墙上,即不会与墙壁线段相交,就add_adge(). 效果图如下: 如何判断呢?

[HDU 4082] Hou Yi&#39;s secret (简单计算几何)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4082 题目大意: 给你n个点,问能最多构成多少个相似三角形. 用余弦定理,计算三个角度,然后暴力数有多少个,更新答案. 代码: 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4 #include <cstring> 5 #include <vector> 6 #includ

POJ 3071 Football(简单 概率DP)

Football 原文链接:http://blog.csdn.net/xuechelingxiao/article/details/38520105 大意:2^n 个球队进行单场淘汰赛,每两只球队之间比赛会有胜负的概率,问最后谁夺冠的概率最大. 思路:简单的概率DP问题,主要是怎么处理哪两个球队比赛的问题. DP方程为 dp[i][j] = ∑(dp[i-1][j]*dp[i-1][k]*p[j][k]); //dp[i][j]表示第 i 轮的时候,第 j 支队伍赢的概率.. 对于其中位运算,可

poj 3077 Rounders 【简单字符串处理】

题意:就是4舍5入到最近的数. 题意有些难理解... 代码: #include <stdio.h> #include <string.h> char s[10]; int main() { int t, n; scanf("%d", &t); while(t --){ memset(s, 0, sizeof(s)); scanf("%s", s); int len = strlen(s); if(len == 1){ printf(&

POJ 3982 序列(JAVA,简单,大数)

题目 //在主类中 main 方法必须是 public static void 的,在 main 中调用非static类时会有警告信息, //可以先建立对象,然后通过对象调用方法: import java.io.*; import java.util.*; import java.math.*; public class Main { /** * @xqq */ public BigInteger a99(BigInteger a, BigInteger b, BigInteger c) { f

poj 3273 Monthly Expence 简单二分

1 /** 2 大意: 有连续的n天,每一天有一定的花费,将其分成m份,每一份占一天或者连续的几天,求这m份中的最大值 3 思路: 二分其最大上限,看在此最大上线,能分成多少份,若大于m份,说明上限过小,需要扩大上限 4 若小于m份,则说明,下限过大,需要缩小上限. 5 **/ 6 #include <iostream> 7 8 using namespace std; 9 int c[100010]; // 记录,每天的花费 10 int main() 11 { 12 int n,m; 13

poj 3368(RMQ简单应用)

Frequent values Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 13317   Accepted: 4894 Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreasing order. In addition to that, you are given several queries cons

POJ 2393 Yogurt factory(简单贪心)

http://poj.org/problem?id=2393 题意:任务规定,一个酸奶制造厂,在n个星期内,分别要向外提供y[i]unit的酸奶.已知这个制造厂第i周制造每unit酸奶的费用为c[i],储存室储存每1unit酸奶1星期的费用为s.问要完成这个任务的最小费用是多少. . . . . . . . . . . . . . 思路:简单贪心.维护一个目前最优的代价minc = min(c, minc + s),然后求和. #include <iostream> using namespa

POJ 2524 Ubiquitous Religions (简单并查集,三种方式)

Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 30791   Accepted: 14928 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi