2012年1月28日
摘要: 此题太恶心了。。。。。(开始的时候思路错了,没有考虑到交点可能是拐点,这是其一。其二,就是精度。。。。。。。尼玛啊,这个害我WA了N次)唉~~~~~精度很重要啊。还有一点就是先判断枚举的直线是否合理,即是否在管道内。然后对于每个拐点映射到直线上的Y值是否在管道里,不是则求出X值。接下来枚举就行。View Code 1 #include<iostream> 2 #include<cstdio> 3 #define EPS 1e-8 4 using namespace std; 5 6 struct point { 7 double x, y; 8 point(double 阅读全文
posted @ 2012-01-28 15:37 Dev-T 阅读(325) 评论(0) 推荐(0) 编辑
  2012年1月17日
摘要: 这题主要用到PICK公式即:area = I + E/2 - 1.(I为多边形内的格点数,E为边上的格点数,area为多边形面积)用GCD可以算出一条边上的格点-1个,那么3×GCD即为3条边上的所有格点数(因为每个条边的顶点多算了一次)。。。View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 struct point { 6 int x, y; 7 }; 8 9 int pick(int area, int num)10 {11 return (area - 阅读全文
posted @ 2012-01-17 16:43 Dev-T 阅读(664) 评论(0) 推荐(0) 编辑
摘要: 这题要注意一点就是数据类型的选择。。。一定要选__int64或者long long,否则很容易出问题。其余的就是直接用公式。。。。。View Code 1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #define MAXN 1000004 5 #define END 5 6 using namespace std; 7 __int64 dir[10][2]; 8 struct point { 9 __int64 x, y; 10 };11 12 char data[MAXN];13 阅读全文
posted @ 2012-01-17 14:57 Dev-T 阅读(256) 评论(0) 推荐(0) 编辑
  2012年1月16日
摘要: 先判断第三点是否与前2点共线,是的话,这4点肯定共面。反之则以这3点确定一个平面方程,以此判断第四点是否在同一个面上。View Code 1 #include<iostream> 2 #include<iostream> 3 #define EPS 1e-8 4 using namespace std; 5 6 struct point { 7 double x, y, z; 8 point (){} 9 point (double _x, double _y, double _z):x(_x),y(_y),z(_z){} 10 }data[4];11 12 ... 阅读全文
posted @ 2012-01-16 18:07 Dev-T 阅读(567) 评论(0) 推荐(0) 编辑
  2012年1月15日
摘要: 这道题很水,不过还是让我纠结了很久,开始数组越界了导致我开的另一个数组的值无故改变,我还以为是编译器的问题,唉~~~~~~~~~~~~此题思路很简单:先求出点与点之间的距离(前提是不与前面的线段规范相交)。然后直接dij过。View Code 1 #include<iostream> 2 #include<cmath> 3 #define EPS 1e-8 4 #define getX(x,y) ((x-1)*4+y+1) 5 #define getY(x,y) ((x-1)*4+y+1) 6 #define MAXN 80 7 #define M 10000000 8 阅读全文
posted @ 2012-01-15 16:19 Dev-T 阅读(277) 评论(0) 推荐(0) 编辑
  2012年1月14日
摘要: 这题乍一看,没有什么思路。不过画了下图,就大概猜到了。当输入为1行或1列时,那么最大值肯定为max(n,m).当输入为2行或2列时,那么最大值也可分析的出来:max(n,m)/4)*4+2(max(n,m)%4 == 1),max(n,m)/4)*4(max(n,m)%4 == 0),max(n,m)/4)*4+4(其他)这三种情况.当输入为其他时,分析可知如果n*m%2 == 0,则为n*m/2.反之则为n*m/2+1.View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 阅读全文
posted @ 2012-01-14 15:32 Dev-T 阅读(299) 评论(0) 推荐(0) 编辑
摘要: 这题只要看下题目的数据量就知道肿么做了。1<=n<=10^9。直接暴力枚举其因子,时间复杂度为O(sqrt(n)*(sqrt(sqrt(n))));想想应该能过,还有一点就是最大最小值的求法:最大值:把3个因子中的最大值加1,其余加2.最小值:把3个因子中的最小值加1,其余加2.介个很容易证明。。。。。。还有一点要用__int64View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 inline __int64 max(__int64 a, __int64 b 阅读全文
posted @ 2012-01-14 15:26 Dev-T 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 唉~~~格式处理题,水题啊。。。。。。细节还是很重要的View Code 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 5 int main() 6 { 7 char data[110]; 8 char newdata[200]; 9 for (int i(0); i<110; ++i)data[i] = '0';10 cin>>data;11 newdata[0] = '$';12 bool flag = false;13 int c 阅读全文
posted @ 2012-01-14 15:20 Dev-T 阅读(218) 评论(0) 推荐(0) 编辑
摘要: 呃。。。暴力水题,不解释。View Code 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 5 bool vis[10]; 6 bool law(int x) 7 { 8 return x<=9 && x>=1 && !vis[x]; 9 }10 11 12 int main()13 {14 for (int i(1); i<=9; ++i)vis[i] = false;15 int c1,c2,r1,r2,d1,d2;16 scanf( 阅读全文
posted @ 2012-01-14 15:17 Dev-T 阅读(178) 评论(0) 推荐(0) 编辑
  2012年1月11日
摘要: 呃。。。。很经典的题目,由于数据量较大,2分的话会比较省时间。就是问你N个方块里面有多少个点。so easy!View Code 1 #include<iostream> 2 using namespace std; 3 int px,py; 4 struct LINE 5 { 6 int Ux, Uy, Lx, Ly; 7 }line[5002]; 8 int sum[5001]; 9 int n, m;10 11 inline int cross(int x1, int y1, int x2, int y2)12 {13 return x1*y2-y1*x2; ... 阅读全文
posted @ 2012-01-11 17:51 Dev-T 阅读(179) 评论(0) 推荐(0) 编辑