HDU 6055 Regular polygon】的更多相关文章

/* HDU 6055 - Regular polygon [ 分析,枚举 ] 题意: 给出 x,y 都在 [-100, +100] 范围内的 N 个整点,问组成的正多边形的数目是多少 N <= 500 分析: 分析可知,整点组成的正多边形只能是正方形 故枚举两个点,验证剩下两个点的位置 坑点: 由于点的范围是 [-100, +100],故经过计算得出的点的范围可能是 [-300,+300],注意越界 编码时长:46分钟(-1) */ #include <bits/stdc++.h> u…
Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1529    Accepted Submission(s): 597 Problem Description On a two-dimensional plane, give you n integer points. Your task is to fig…
题目链接 **Problem Description On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make. Input The input file consists of several test cases. Each case the first line is a…
Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2004    Accepted Submission(s): 795 Problem Description On a two-dimensional plane, give you n integer points. Your task is to fig…
Regular polygon Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2219    Accepted Submission(s): 880 Problem Description On a two-dimensional plane, give you n integer points. Your task is to fig…
http://acm.hdu.edu.cn/showproblem.php?pid=6055 [题意] 给定n个格点,问有多少个正多边形 [思路] 因为是格点,只可能是正方形 枚举正方形的对角线,因为有两条对角线,最后答案要/2 也可以枚举正方形的边,因为有四条边,答案要/4 看当前对角线确定的正方形是否存在,用几何知识求出目标点的坐标,然后二分查找目标点是否存在 [Accepted] #include <cstdio> #include <cstring> #include &l…
题意,二维平面上给N个整数点,问能构成多少个不同的正多边形. 析:容易得知只有正四边形可以使得所有的顶点为整数点.所以只要枚举两个点,然后去查找另外两个点就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #inclu…
题目链接 有个结论: 平面坐标系上,坐标为整数的情况下,n个点组成正n边形时,只可能组成正方形. 然后根据这个结论来做. 我是先把所有点按照 x为第一关键字,y为第二关键字 排序,然后枚举向量 (p[i]->p[j]) (j>i),只判断这个向量左侧可否存在两个点与它一起构成一个正方形.这样算的结果是,计数每个正方形时,它的靠右和靠下的两条边都会为ans贡献一个单位,所以最后ans要除以2. #include<bits/stdc++.h> using namespace std;…
题目链接 给一个n个顶点的正多边形, 给出多边形内部一个点到n个顶点的距离, 让你求出这个多边形的边长. 二分边长, 然后用余弦定理求出给出的相邻的两个边之间的夹角, 看所有的加起来是不是2Pi. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #includ…
Problem Description On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make.   Input The input file consists of several test cases. Each case the first line is a numbe…
/** 题目:hdu6055 Regular polygon 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6055 题意:给定n个坐标(x,y).x,y都是整数,求有多少个正多边形.因为点都是整数点,所以只可能是正四边形. 思路: (x1,y2)(x2,y2)=>(x,y) = (x2-x1,y2-y1) 向量(x,y)逆时针旋转90度:(-y,x):那么可以得到垂直(x,y)的向量,并通过(x2,y2)获得以(x2,y2)为起点的向量终点(x2+(…
Description On a two-dimensional plane, give you n integer points. Your task is to figure out how many different regular polygon these points can make.   Input The input file consists of several test cases. Each case the first line is a numbers N (N…
思路:三角形的圆心角可以整除(2*pi)/n #include<cstdio> #include<cstring> #include<iostream> #include<queue> #include<stack> #include<algorithm> using namespace std; #define clc(a,b) memset(a,b,sizeof(a)) #define inf 0x3f3f3f3f ; #defi…
Regular Number http://acm.hdu.edu.cn/showproblem.php?pid=5972 题意: 给定一个字符串,求多少子串满足,子串的第i位,只能是给定的数(小于等于9). 分析: Shift_and算法.bitset优化. bitset<N>p[26]:p[c]表示字符c在子串出现的位置的集合. bitset<N>ans:ans[i]表示能否匹配到i位. 在扫一遍母串的过程中,每扫到一位,ans=(ans<<1)|1,表示试图增加一…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1502 思路:给定一个n,分别由n个a,b,c组成的字符串的所有前缀中a的个数大于等于b的个数大于等于c的个数,求满足这一条件的字符串的个数有多少,本题要用到dp及大数运算,转移方程:dp[i][j][k]=dp[i-1][j][k]+dp[i][j-1][k]+dp[i][j][k-1],其中i,j,k分别代表a,b,c的个数 老实说并不会写大数,不过发现了一段很神奇的代码 #include<iostr…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1502 题目大意:找出总的满足条件的字符串数,num(a)=num(b)=num(c)且任何前缀均满足num(a)>=num(b)>=num(c) 解题思路:用dp[i][j][k]表示a取i个,b取j个,c取k个的状态下最多有多少种满足条件的情况,容易推得状态转移方程如下: dp[i][j][k]=dp[i-1][j][k](i>j时)+dp[i][j-1][k](j>k时)+dp[i…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5972 [题目大意] 给出一个字符串,找出其中所有的符合特定模式的子串位置,符合特定模式是指,该子串的长度为n,并且第i个字符需要在给定的字符集合Si中 [题解] 利用ShiftAnd匹配算法. bt[i]表示字符i允许在哪些位置上出现,我们将匹配成功的位置保存在dp中,那么就可以用dp[i]=dp[i-1]<<1&bt[s[i]]来更新答案了 利用滚动数组和bitset可以来优化这样的…
题目链接 题意 给定两个串\(S,T\),找出\(S\)中所有与\(T\)匹配的子串. 这里,\(T\)的每位上可以有若干(\(\leq 10\))种选择,匹配的含义是:对于\(S\)的子串的每一位,\(T\)的相应位都有一种选择与之对应. 题解 shift-and算法详解 https://www.douban.com/note/321872072/ 搜出来的题解全都是\(shift-and\)的.... 学习了一波...然而并不明白\(kmp\)为什么不可以.... 看到这道题直觉就是和hdu…
题意: 一个单词X由{A,B,C}三种字母构成. A(X):单词X中A的个数.B(X),C(X)同理. 一个单词X如果是regular word必须满足A(X)=B(X)=C(X)且对于X的任意前缀有A(X)>=B(X)>=C(X). 给一个数n.问长度为3n的regular word有多少个. 思路: dp[a][b][c]:前a+b+c个字母由a个A,b个B,c个C构成. 然后就可以分解了,,, *:用到高精度 代码: int const MAXN=99999999; int const…
题意:给出两点,求经过这两点的正n边形的最小面积 题解:这两点一定是最长的弦,我们设正多边形中点c,找到c到每个点的距离(都相同) 我们知道那个等腰三角形的底与每个角度就使用余弦定理 #include<set> #include<map> #include<queue> #include<stack> #include<cmath> #include<vector> #include<string> #include<…
题意:问按规则排成的串有多少个A(c)>= B(c) >= C(c) 思路:因为写大整数太累,就偷懒了一下直接用java水过 import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args){ BigInteger [][][]dp=new BigInteger [65][65][65]; dp[0][0][0]=BigInteger…
题意:给定两个点A和B,求包含这两个点的面积最小的正 n(已知)边形. #include<iostream> #include<iomanip> #include<cmath> #define pi 2.0*asin(1.0) #define sqr(a) ((a)*(a)) using namespace std; int main() { int n; double x1,x2,y1,y2,d,thy,s; while(cin>>x1>>y1…
题目链接  HDU5972 2016 ACM/ICPC 大连区域赛 B题 我们预处理出$b[i][j]$,$b[i][j] = 1$的意义是数字$i$可以放在第$j$位. 然后就开始这个匹配的过程. 假设字符串第一位下标从$1$开始 我们每一次处理的子串为$s[i-n+1]$,$s[i-n+2]$, $s[i-n+3]$, ..., $s[i]$ $ans[k] = 1$的含义是 $s[i-k+1], s[i-k+2], s[i-k+3], ..., s[i]$这k位可以与$t[1], t[2]…
[Link]: [Description] 给你n个点整数点; 问你这n个点,能够组成多少个正多边形 [Solution] 整点只能构成正四边形. 则先把所有的边预处理出来; 枚举每某两条边为对角线的情况; 看看这两条对角线能否组成一个正方形; 可以的话,递增答案. [NumberOf WA] 1 [Reviw] (排序的时候边的数目和点的弄混了) [Code] #include <bits/stdc++.h> #define int long long using namespace std…
题意略. 思路:要你找出所有正多边形,其实是唬人的,整点的正多边形只有正方形,具体证明可以参考     2017国家队论文集-<正多边形>-杨景钦 详见代码: #include<bits/stdc++.h> #define maxn 505 //#define LOCAL using namespace std; struct Point{ int x,y; Point(,){ x = a,y = b; } Point operator+ (const Point& p){…
Regular Polygon Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 3274    Accepted Submission(s): 996 Problem Description In a 2_D plane, there is a point strictly in a regular polygon with N side…
Dancing Stars on Me Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5533 Description The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, somet…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533 Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 601    Accepted Submission(s): 320 Problem Description The sky was brush…
Birthday Toy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 644    Accepted Submission(s): 326 Problem Description AekdyCoin loves toys. It is AekdyCoin’s Birthday today and he gets a special “…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 186    Accepted Submission(s): 124 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl…