随笔分类 -  hdu刷题

巨水的题目
摘要:// 今天翻了翻以前收藏的东西,居然发现: spfa 用map 写的 ,好吧,stl 我一无所知。题目:hdu 2544 太熟悉了吧#include<stdio.h>#include <map>#include <queue>#define N 101using namespace std;map<int,int> head[N];// head[u][v]=wint spfa(int st,int n) //start{ int i,u,v,w; int vis[N],d[N]; for (i=1;i<=n;i++) {vis[i]=0; 阅读全文

posted @ 2012-05-02 21:24 skyming 阅读(202) 评论(0) 推荐(0)

HDU 4033 Regular Polygon(二分+高精度)
摘要:比赛时没做出来,最后10 钟时倒是想枚举每个角度,精度估计上可能会出问题;后来听“理宝”说可以暴力枚举边的长度,精确到0.001,数据恰好10^7,T_T~~vongang说可以用二分做,也就是官方解题报告的解法:这题用二分的关键是: 首先Regular Polygon是正多边形,: 想到边长和所对的角成正比,没想到啊,Orz,各路大神贴个山寨的代码吧:#include<stdio.h>#include<math.h>#define N 110const double inf =10000;const double pi=acos(-1.0);const double 阅读全文

posted @ 2012-04-05 20:47 skyming 阅读(377) 评论(0) 推荐(0)

hdu 1598 find the most comfortable road
摘要:思路:快排+并查集#include<stdio.h>#include<algorithm>#define inf 999999using namespace std;struct node{ int s,e,w;}road[1005];int xx[1005];int cmp(node a,node b){ return a.w<b.w;}int find(int x){ while(x!=xx[x]) x=xx[x]; return x;}int main(){ int n,m; while(~scanf("%d%d",&n,& 阅读全文

posted @ 2011-11-27 21:58 skyming 阅读(256) 评论(0) 推荐(0)