题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5533 题意:平面图中 有n个点给你每个点的坐标,判断是否能通过某种连线使得这些点所组成的n边形为 正n变形: 很容易发现在一个n变形中,所有的点之间的距离只有n/2种,所以我们只需判断一下这n个点之间的距离是否只有n/2种即可; #include<stdio.h> #include<string.h> #include<algorithm> #include<iost…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 592    Accepted Submission(s): 315 Problem Description The sky was brushed clean by the wind and the stars were cold in a b…
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…
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…
Dancing Stars on Me Problem 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, sometimes the stars can form a regular polygon in the sky if we connect them properly. Yo…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 223    Accepted Submission(s): 151 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl…
Problem 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, sometimes the stars can form a regular polygon in the sky if we connect them properly. You want to record the…
Problem 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, sometimes the stars can form a regular polygon in the sky if we connect them properly. You want to record the…
链接:传送门 题意:给出 n 个点,判断能不能构成一个正 n 边形,这 n 个点坐标是整数 思路:这道题关键就在与这 n 个点坐标是正整数!!!可以简单的分析,如果 n != 4,那一定就不能构成正 n 边形,否则暴力一下找到最小距离,这个最小距离一定是最短边长,暴力查找一下等于这个边长边的个数,如果是 4 个就能构成正 4 边形了 balabala: 分析 + 暴力出奇迹,出题人还是蛮有趣的!希望能在比赛中get到这些关键点. A strong man will struggle with t…
题意:给定二维平面上的n个整点,问它们是否都在正n边形的定点上 n<=100,abs(x[i]),abs(y[i])<=1e4 思路:队友做的,抱大腿 可以发现只有n=4时顶点有可能都是整点,判一下对角线与边长就行 我与队友互演,WA了5发…… #include<bits/stdc++.h> using namespace std; #define LL long long ; struct node{ int x,y; }a[maxn]; int dis(int i,int j)…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2002    Accepted Submission(s): 1168 Problem Description The sky was brushed clean by the wind and the stars were cold in a…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 286    Accepted Submission(s): 185 Problem Description The sky was brushed clean by the wind and the stars were cold in a bl…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1098    Accepted Submission(s): 598 Problem Description The sky was brushed clean by the wind and the stars were cold in a b…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 582    Accepted Submission(s): 308 Problem Description The sky was brushed clean by the wind and the stars were cold in a b…
5532 Almost Sorted Array 题目大意:给你一个序列,如果它拿掉其中一个数后,可以是该序列成为非递减或非递增序列,则输出YES. 有两种思路,第一种代码比较简单,是LIS,复杂度nlogn,第二种是On的复杂度. LIS的代码如下. #include <set> #include <queue> #include <cstdio> #include <vector> #include <cstring> #include &l…
Dancing Stars on Me Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2460    Accepted Submission(s): 1420 Problem Description The sky was brushed clean by the wind and the stars were cold in a…
弱没机会去长春,但拿了题来做了,加上请教各路大牛,理论AC了一发,但没实现~(感谢各路有形无形的大牛的指导) A题~Too Rich 给你1,5,10,20,50,100,200,500,1000,2000这几个数的个数,用最多的数组成和为p. 解:一眼看上去像个贪心题,其实,如果没有20,50,200,500这样怪的数,确实只是一个 简单的贪心题.转换一下题目,求p用最多的数组成,设S是所有数的和,即要求s-p用最少的 数组成.对于60,如果贪心的话,对20,20,20,50而言,很明显会造成…
精确覆盖问题的定义:给定一个由0-1组成的矩阵,是否能找到一个行的集合,使得集合中每一列都恰好包含一个1 例如:如下的矩阵 就包含了这样一个集合(第1.4.5行) 如何利用给定的矩阵求出相应的行的集合呢?我们采用回溯法 矩阵1: 先假定选择第1行,如下所示: 如上图中所示,红色的那行是选中的一行,这一行中有3个1,分别是第3.5.6列. 由于这3列已经包含了1,故,把这三列往下标示,图中的蓝色部分.蓝色部分包含3个1,分别在2行中,把这2行用紫色标示出来 根据定义,同一列的1只能有1个,故紫色的…
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时则按照横坐标从小到大输出. (0 <= x, y <= 32000) 要求输出等级0到n-1之间各等级的星星个数. 分析: 这道题不难想到n平方的算法,即从纵坐标最小的开始搜,每次找它前面横坐标的值比它小的点的个数,两个for循环搞定,但是会超时. 所以需要用一些数据结构去优化,主要是优化找 横坐…
Moon Game Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Description Fat brother and Maze are playing a kind of special (hentai) game in the clearly blue sky which we can just consider as a kind of two-dime…
dancing link简直是求解数独的神器,NOIP2009最后一题靶形数独,DFS 各种改变搜索顺序 都没法过,最后还是用了卡时过得.用dancing link写,秒杀所有数据,总时间才400ms不到..(虽然还不是很清楚为什么会快). 一开始还是先看这个blog,图文都非常清晰 http://www.cnblogs.com/grenet/p/3145800.html 上文解释了dancing link的原理,可以用来解决精度覆盖问题,但是求解数独问题还需要一步转化. 见博文: http:/…
Problem D Dancing Digits 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=112&page=show_problem&problem=2139 题目意思: 给你{1,2,3,4,5,6,7,8}的一个排列,其中每个数带负号或带正号,通过插入的方法将这些数按绝对值从小到大排序,输出插入的最小步数,如果不可能完成输出-1,能否插入的要求是…
Saint John Festival 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/J Description Porto's Festa de São João is one of Europe's liveliest street festivals. Its peak is the night of 23rd to 24th of June, with dancing parties from Ribeira to…
转载自:http://www.cnblogs.com/grenet/p/3145800.html 精确覆盖问题的定义:给定一个由0-1组成的矩阵,是否能找到一个行的集合,使得集合中每一列都恰好包含一个1 例如:如下的矩阵 就包含了这样一个集合(第1.4.5行) 如何利用给定的矩阵求出相应的行的集合呢?我们采用回溯法 矩阵1: 先假定选择第1行,如下所示: 如上图中所示,红色的那行是选中的一行,这一行中有3个1,分别是第3.5.6列. 由于这3列已经包含了1,故,把这三列往下标示,图中的蓝色部分.…
Dancing Links解决Exact Cover问题. 用到了循环双向十字链表. dfs. 论文一知半解地看了一遍,搜出一篇AC的源码,用注释的方法帮助理解. HIT ACM 感谢源码po主.链接如下: http://blog.csdn.net/yysdsyl/article/details/4266876 #include <iostream> #include <cstdio> using namespace std; const int INT_MAX = 2147483…
Swift提供了所有c类语言的控制流结构.包括for和while循环来执行一个任务多次:if和switch语句来执行确定的条件下不同的分支的代码:break和continue关键字能将运行流程转到你代码的另一个点上. 除了C语言传统的for-condition-increment循环,Swift加入了for-in循环,能更加容易的遍历arrays, dictionaries, ranges, strings等其他序列类型. Swift的switch语句也比C语言的要强大很多. Swift中swi…
在“跳跃的舞者,舞蹈链(Dancing Links)算法——求解精确覆盖问题”一文中介绍了舞蹈链(Dancing Links)算法求解精确覆盖问题. 本文介绍该算法的实际运用,利用舞蹈链(Dancing Links)算法求解数独 在前文中可知,舞蹈链(Dancing Links)算法在求解精确覆盖问题时效率惊人. 那利用舞蹈链(Dancing Links)算法求解数独问题,实际上就是下面一个流程 1.把数独问题转换为精确覆盖问题 2.设计出数据矩阵 3.用舞蹈链(Dancing Links)算法…
Stars in Your Window Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13196   Accepted: 3609 Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beaut…
abastract:利用dancing links 解决精确覆盖问题,例如数独,n皇后问题:以及重复覆盖问题. 要学习dacning links 算法,首先要先了解该算法适用的问题,精确覆盖问题和重复覆盖问题等,下面先了解精确覆盖问题和重复覆盖问题. 精确覆盖问题 何为精确覆盖问题 在一个全集X中若干子集的集合为S,精确覆盖(Exactcover)是指,S的子集S*,满足X中的每一个元素在S*中恰好出现一次. 定义 满足以下条件的集合为一个精确覆盖:  S*中任意两个集合没有交集,即X中的元素在…