上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 26 下一页
摘要: A:简单题: 1 #include 2 using namespace std; 3 4 int n,k; 5 int main() 6 { 7 scanf("%d%d",&n,&k); 8 for(int i=0; i 2 using namespace std; 3 4 int n,k; 5 int main() 6 { 7 scanf("%d%d",&n,&k); 8 if((n==1&&k==1)||k==n) 9 {10 puts("-1");11 return 0;12 }1 阅读全文
posted @ 2013-11-12 10:43 Yours1103 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 题目给我们四个点,要求我们以这四个点为圆心,形成四个相切的圆;求他们的半径和;首先我们从他们中间选出三个点,以这三个点为圆心的三个圆最大可以两两互相相切;证明:假设这三个圆的半径分别为a,b,c,那么形成的三条边分别长为:a+b,a+c,b+c,他们两两之和大于第三边;然后从第四个点出发的圆必定和前面三个的一个或多个相切;所以这个问题就转化成为三对边和的比较;代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 double dis(double x1,double y1,double x2,double y2) 6 { 7 阅读全文
posted @ 2013-11-11 19:45 Yours1103 阅读(117) 评论(0) 推荐(0) 编辑
摘要: A:要么是两次要么4次,判断是否在边界; 1 #include 2 using namespace std; 3 4 int main() 5 { 6 int n,m,x; 7 bool flag=0; 8 scanf("%d%d",&n,&m); 9 for(int i=0; i 2 using namespace std; 3 4 int main() 5 { 6 int n,k; 7 scanf("%d%d",&n,&k); 8 for(int i=1;i 2 #include 3 #include 4 #defin 阅读全文
posted @ 2013-11-11 10:56 Yours1103 阅读(113) 评论(0) 推荐(0) 编辑
摘要: A - Dima and Continuous Line水题:直接模拟; 1 #include 2 #define maxn 1005 3 using namespace std; 4 int x[maxn],y[maxn]; 5 int main() 6 { 7 int n,a,b,last; 8 scanf("%d",&n); 9 bool flag=1;10 for(int i=0;ib)17 {18 a=a^b;19 b=a^b;20 a=a^b;21 ... 阅读全文
posted @ 2013-11-11 10:51 Yours1103 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 思路:二分答案,然后模拟消灭石头的过程;如果单纯的暴力模拟的话,肯定会T的;所以要用到一定的技巧来维护;在网上看到大神们用O(n)的复杂度来优化,真心orz;原理是这样的:用一个变量sum_2存前面所有的对当前石头造成影响的冲击波的损失的能量和;所以对于当前的石头所需要的新的冲击波的数量为:(当前石头的能量值-前面有影响的冲击波数*能量x+sum_2)/能量x+1;然后就是维护sum_2了!维护sum_2要利用这个公式:(x+1)^2=x^2+2*x+1; 1 #include 2 #define maxn 50005 3 #define ll long long 4 using namesp 阅读全文
posted @ 2013-11-08 19:55 Yours1103 阅读(417) 评论(0) 推荐(0) 编辑
摘要: 一个很简单的2-sat的题;不过比较难想到;其实也不是很难,可能接触的少了吧! 1 #include 2 #include 3 #define maxn 10009 4 using namespace std; 5 6 struct twosat 7 { 8 int n; 9 vectorg[maxn*2];10 bool mark[maxn*2];11 int s[maxn*2],c;12 13 bool dfs(int x)14 {15 if(mark[x^1])return 0;16 if(mark[x])... 阅读全文
posted @ 2013-11-06 23:02 Yours1103 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 一个二分图最大匹配的题;匈牙利算法不熟;建了个模,用最小费用最大流解决了 1 #include 2 #include 3 #define INF 9999999 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 #define maxn 6100 10 11 struct edge 12 { 13 int from,to,cap,flow,cost; 14 }; 15 struct MCMF 16 { 17 int n,m,s,t; 18 vector... 阅读全文
posted @ 2013-11-06 22:18 Yours1103 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 对x的坐标三分; 1 #include 2 #include 3 #define maxn 10009 4 using namespace std; 5 double a[maxn],b[maxn],c[maxn]; 6 int n; 7 double f(double x) 8 { 9 double ans=-999999999.0,t;10 for(int i=0;i<n;i++)11 {12 t=a[i]*x*x+b[i]*x+c[i];13 ans=max(ans,t);14 }15 return ans;16 }... 阅读全文
posted @ 2013-11-06 21:06 Yours1103 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 半平面交,二分;注意,题目的点是顺时针给出的; 1 #include 2 #include 3 #include 4 #define maxn 50010 5 #define eps 1e-6 6 using namespace std; 7 8 int dcmp(double x) 9 { 10 return fabs(x) 0 ? 1 : -1); 11 } 12 13 struct Point 14 { 15 double x; 16 double y; 17 Point(double x = 0, double y = 0):x(... 阅读全文
posted @ 2013-11-05 20:56 Yours1103 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 半平面交的题;这个题目的亮点就是建模; 1 #include 2 #include 3 #include 4 #define maxn 109 5 #define eps 1e-6 6 using namespace std; 7 8 int dcmp(double x) 9 { 10 return fabs(x) 0 ? 1 : -1); 11 } 12 13 struct Point 14 { 15 double x; 16 double y; 17 Point(double x = 0, double y = 0):x(x), y(... 阅读全文
posted @ 2013-11-05 20:33 Yours1103 阅读(156) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 26 下一页