摘要: 水题,DFS+记忆化View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 int n,m,s,d,e[105][105],ok[105],cover[105]; 4 int find(int x) 5 { 6 int i; 7 if(ok[x]==1)return 1; 8 for(i=1;i<=e[x][0];i++) 9 if(cover[e[x][i]]==0)10 {11 cover[e[x][i]]=1;12 ok[x]=ok[... 阅读全文
posted @ 2012-03-13 21:47 ustc-acm 阅读(156) 评论(0) 推荐(0) 编辑
摘要: #include<string.h>#include<stdio.h>char s1[200000],s2[200000],s3[200000],s4[200000];long long a[200000],p[200000],q[200000],num[200000],v[200000];int main(){ int t,n,m,i,j,k; scanf("%d",&t); while (t-->0) { scanf(" %s",s1); scanf(" %s",s2); n=strlen(s 阅读全文
posted @ 2012-03-13 14:07 ustc-acm 阅读(311) 评论(1) 推荐(0) 编辑
摘要: //搜索//策略:先对横轴扩展,得可能解横轴区域,再验证纵轴。对纵轴相同操作 1 #include<stdio.h> 2 int save[310][310]; 3 int main () 4 { 5 int n,m; 6 while (scanf ("%d%d",&n,&m)!=EOF) 7 { 8 int t; 9 scanf ("%d",&t);10 int i,j,p;11 for (i=0;i<n;i++)12 for (j=0;j<m;j++)13 ... 阅读全文
posted @ 2012-03-11 19:02 ustc-acm 阅读(452) 评论(2) 推荐(0) 编辑
摘要: #include<stdio.h>#include<string.h>inline void swap(int & a,int & b){ int k=a; a=b; b=k;}const int N=50;long long binomial[N+1][N+1];void init(){ int i,j; for (i=0;i<=N;i++) { binomial[i][0]=binomial[i][i]=1; for (j=1;j<i;j++) { binomial[i][j]=binomi... 阅读全文
posted @ 2012-03-11 17:19 ustc-acm 阅读(417) 评论(0) 推荐(0) 编辑
摘要: #include<stdio.h>#include<math.h>#include<vector>#include<algorithm>using namespace std;inline double sqr(double x){ return x*x;}struct Point{ int x,y; int time; bool operator < (const Point & p2) const { return time<p2.time; } double operator ^ (const Point & p 阅读全文
posted @ 2012-03-11 17:19 ustc-acm 阅读(426) 评论(0) 推荐(0) 编辑
摘要: 题目大意:给出一个椭圆和平面上的一些点,求椭圆最多覆盖的点数。其中椭圆长短轴方向固定不可旋转。思路:首先将图的横纵坐标乘上一定系数使椭圆覆盖问题变为圆覆盖问题。可以很容易地证明,一定存在一个最优解使得圆周上存在两个或两个以上地点。由于圆的半径一定,所以枚举圆周上的两个点,可算出圆的位置(可能有两个不同的圆),再求出覆盖点数并取最优解。#include <stdio.h>#include "stdlib.h"#include "math.h"double dis(double x1,double y1,double x2,double y2){ 阅读全文
posted @ 2012-02-28 14:15 ustc-acm 阅读(389) 评论(0) 推荐(0) 编辑
摘要: 这题很水,找规律就能过...1。先考虑如果m,n至少有一个是偶数,根据对称性,答案就是对角线长的一半2。然后m,n都是奇数的情况,画一下3X5,3X7的看一下,规律一眼就看出来了...- -先同除以最大公约数,然后根据刚刚找到的规律(假设m>n,根据三角形相似,答案与对角线的比例=n/m+(n-2)/m+..+3/m+1/m+1/m+3/m+...+(n-2)/m+n/m,如果不足 (m+n)/2项的话,差多少个就加多少个n/m补足)可以推出答案是对角线长度(m*n+1)/(2*m*n)倍View Code 1 #include<stdio.h> 2 #include< 阅读全文
posted @ 2012-02-27 17:40 ustc-acm 阅读(424) 评论(0) 推荐(1) 编辑
摘要: 考试时很诡异的考虑到了类似俄罗斯方块的情形,就像是天上不停的下高为h的俄罗斯方块,然后根据下面的方块高度来进行新的高度的判断。很容易想到DP方程,设第i个方块能达到的高度为F[i],有F[i]=max{F[i]+H[i]},其中1<=j<=i-1,H[i]为第i个方块的高度。判定第i,j个方块是否有重合部分只需分别对x和y坐标做判定即可。View Code 1 #include<stdio.h> 2 #include<stdlib.h> 3 struct data{ 4 int a,b,h,x,y 5 }a[1001]; 6 int f[1001],n,m, 阅读全文
posted @ 2012-02-26 22:02 ustc-acm 阅读(391) 评论(0) 推荐(0) 编辑
摘要: 这道题是一区间统计,注意炸弹炸的是线段,最后要求的是最大的损坏值D_max,最左的具有D_max的线段的左起点,和,最右的具有D_max的线段的右起点。因为是离线统计(废话,炸着炸药你就去修路啊~~),所以未必要用线段树全长 [0, len] 在数轴上。离散也就是 0, 1, … , len-1 ( n = [n, n+1] )101 5 26 9 2也就是[5, 6]无损把[a, b] +d拆成 [a, infinity] +d, [b,infinity] -d即可。O, 上面理解错了,还是理解成点【0,len】也就是len+1个点,对【a,b】操作就是对(b-a+1)个点操作2781797 阅读全文
posted @ 2012-02-26 17:21 ustc-acm 阅读(423) 评论(1) 推荐(0) 编辑
摘要: 题目大意:给出n条直线,求将x=a,x=b所围区域分成多少个小区域。思路:n条直线对应[a,b]区域内n条线段。按线段左端点排序,求右端点的逆序对。View Code 1 #include<iostream> 2 #include<stdio.h> 3 #include<string.h> 4 #include<algorithm> 5 #define MAX 31000 6 using namespace std; 7 typedef struct Line{ 8 int x,y; 9 };10 Line c[MAX];11 int f[MAX 阅读全文
posted @ 2012-02-26 14:49 ustc-acm 阅读(255) 评论(1) 推荐(0) 编辑