10 2013 档案
摘要:http://poj.org/problem?id=2187题意:求凸包上最远点距离的平方思路:开始用旋转卡壳求的最远点,WA,改了好久。。后来又改成枚举凸包上的点。。AC了。。 1 #include 2 #include 3 #include 4 using namespace std; 5 const int N=50005; 6 int n; 7 struct Point 8 { 9 int x,y;10 Point(int x = 0,int y = 0):x(x),y(y) {}11 bool friend operator 1&&Cross(ch[m...
阅读全文
摘要:http://poj.org/problem?id=1113题意:给出一些点的坐标,和一个半径r,求出这些点围成的凸包的周长再加上一个半径为r的圆的周长。 1 #include 2 #include 3 #include 4 const double PI=acos(-1.0); 5 const int N=1002; 6 using namespace std; 7 8 struct Point 9 {10 double x;11 double y;12 Point (double x = 0,double y = 0):x(x),y(y) {}13 ...
阅读全文
摘要:http://poj.org/problem?id=3258题意理解起来很别扭,觉得自己描述的会让人搞不懂,建议去搜一下正规的解释。 1 #include 2 #include 3 #include 4 #include 5 const int N=100010; 6 using namespace std; 7 int main() 8 { 9 int L,n,m,d[N];10 scanf("%d %d %d",&L,&n,&m);11 d[0] = 0;//第一块石头的距离12 d[n+1] = L;//最后一块石头的距离13 for (i..
阅读全文
摘要:http://poj.org/problem?id=3122题意:将n个圆柱体的不同口味的pie分给m个人,要求每个人分得的pie必须体积相同,且来自于一块pie(即:只分得一种口味的pie),求最多每个人可分得的体积。思路:理解了题意就好做了,二分并注意精度。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const double PI=acos(-1.0); 7 const double eps=1e-8;//设置精度 8 const int N=10008; 9 int main()10 ...
阅读全文
摘要:http://poj.org/problem?id=2031题意:给出n个球的圆心坐标x,y,z, 半径r,若任意两球不相交,则在两球间建桥。问需建桥的最短距离是多少。思路:建图,以两球间相差的距离为权值,然后求最小生成树。 1 #include 2 #include 3 #include 4 const int inf=1 Map[pos][j])38 dis[j] = Map[pos][j];39 }40 }41 }42 void init()43 {44 sum = 0;45 memset(vis,0,size...
阅读全文
摘要:http://poj.org/problem?id=1408题意:给出a1 a2 ... an b1 b2 ... bn c1 c2 ... cnd1 d2 ... dn 这些点,求这些对应点连线形成的小四边形的最大面积。思路:将所有的交点求出,同已知点一起存入二维矩阵中,枚举每个小四边形,求出其面积,找出最大的即可。 1 #include 2 #include 3 #include 4 const double eps=1e-8;//设置精度 5 #define max1(a1,b1) (double)a1-(double)b1>eps?(double)a1:(double...
阅读全文
摘要:http://poj.org/problem?id=1265题意:起始为(0,0),给出每个点的偏移量,求依次连接这些点形成的多边形边界上格点的个数。思路:先将各个点的坐标求出存入,由pick定理知:面积 =内部格点数目+边上格点数目/2-1;每条边边格点数目 = gcd(x2-x1,y2-y1);内部格点数目 = 面积+1-边界格点数目/2; 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 struct node 7 { 8 int x; 9 int y;10 } point[1...
阅读全文
摘要:http://poj.org/problem?id=1905题意:已知一根线的长度L,受温度影响膨胀后的弧长s = (1+n*c)*L,求膨胀后与膨胀前的最大距离h。思路:二分枚举h,通过推出的公式算出ss,不断改变h的上下界,使ss不断接近s,因为数据为double型,比较时应注意精度问题。修改:(上式应为(r-h)^2) 1 #include 2 #include 3 const double eps=1e-8; 4 int main() 5 { 6 double L,c,n; 7 while(~scanf("%lf%lf%lf",&L,&c,&
阅读全文
摘要:http://poj.org/problem?id=3273题意:将n个数分成连续的m组,使得这些组里的数的最大的和最小,输出这个组的和。思路:根据上下界二分逼近。。 1 #include 2 #include 3 #include 4 using namespace std; 5 6 int main() 7 { 8 int cost[100010]; 9 int n,m,high = 0,low = 0;10 scanf("%d %d",&n,&m);11 for (int i = 0; i mid)26 {27 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1269连着做了三个基本的dfs,终于弄懂了搜索和回溯的过程。此题要求输出所有路径,首先给每一个点编号0~n+m;则存储时只需存储编号,由编号得到坐标的方式: x = num/m, y = num%m; 由坐标得到编号的方式:num = x*m+y;注意:本题坐标从(1,1)开始,编号后的坐标从(0,0)开始。 1 #include 2 #include 3 const int Max = 20; 4 int map[Max][Max],vis[
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1590 1 #include 2 #include 3 int n,m,s_x,s_y,e_x,e_y; 4 char map[15][15]; 5 6 int Deal(char c) 7 { 8 if(c=='R'&&map[s_x][s_y+1]!='#') 9 {10 s_y++;11 if (s_x==e_x&&s_y==e_y)12 return 1;13 ...
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2449 1 #include 2 #include 3 const int N=520; 4 int vis[N][N],map[N][N]; 5 int n,m,cnt; 6 void dfs(int x,int y) 7 { 8 if (x==n&&y==m) 9 {10 cnt++;11 return ;12 }13 if (x-1>=1&&map[x-1][y]==0&&!vis[.
阅读全文
摘要:http://poj.org/problem?id=2115题意:给出A,B,C和k(k表示变量是在k位机下的无符号整数),判断循环次数,不能终止输出"FOREVER".即转化成 c*x = b-a mod (2^k), 解这个模线性方程的最小正整数解。模板题,代码很短,但是很难理解的样子。。。转载了一些有关的资料。。。 1 #include 2 #define LL long long 3 4 LL Extend_Euclid(LL a,LL b,LL & x,LL & y)//扩展欧几里得 5 { 6 if (!b) 7 { 8 x = 1; 9 ...
阅读全文
摘要:http://poj.org/problem?id=1260 1 #include 2 #include 3 #include 4 5 using namespace std; 6 int main() 7 { 8 int t,dp[120],s[120]; 9 cin>>t;10 while(t--)11 {12 int n,ai[120],pi[120];13 cin>>n;14 s[0] = 0;15 for (int i = 1; i >ai[i]>>pi[i];18 ...
阅读全文
摘要:http://poj.org/problem?id=3267题意:给出一个主串,一些单词,匹配这些单词,问至少要删除多少字符。 1 #include 2 #include 3 #include 4 #include 5 #include 6 int dp[350];//dp[i]表示i->L删除的字符数 7 using namespace std; 8 int main() 9 {10 int n,L;11 string word[606],s;12 cin>>n>>L;13 cin>>s;14 for (int i = 0; i >word[.
阅读全文
摘要:B. Jeff and Periodstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputOne day Jeff got hold of an integer sequence a1, a2, ..., an of length n. The boy immediately decided to analyze the sequence. For that, he needs to find all values of x, for which
阅读全文
摘要:A. Jeff and Digitstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputJeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible
阅读全文

浙公网安备 33010602011771号