__int64 C(__int64 n, __int64 m){__int64 s = 1;int i, j;for (i=1,j=n; i<=m; i++, j--)s = s * j / i;return s;}void init(){ for(int i=0;i<maxn;i++){ c[i][0]=1; c[i][i]=1; for(int j=1;j<i;j++) c[i][j]=c[i-1][j-1]+c[i-1][j]; }} Read More
posted @ 2011-10-06 21:52 Because Of You Views(235) Comments(0) Diggs(0) Edit
计算几何好题View Code #include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>#include<algorithm>using namespace std;const double eps =1e-9;const double PI = acos(-1);struct point { double x,y;}a[1000];double b[2000];__int64 C(int a,int b){ int i; __int64 aa=a,bb Read More
posted @ 2011-10-06 21:51 Because Of You Views(257) Comments(0) Diggs(0) Edit
蛮2巧妙的思路,有点被标记了,才去更新这个点所能更新的最短路径,;此时要利用floyd的思想View Code #include<stdio.h>#include<string.h>const int INF = 999999999;int n,m,q;int map[310][310];int vis[310];void floyd(int x){ int i,j; for(i=0;i<n;i++) for(j=0;j<n;j++) if(map[i][x]+map[x][j]<map[i][j]) map[i][j]= map[i]... Read More
posted @ 2011-10-06 17:33 Because Of You Views(338) Comments(0) Diggs(0) Edit
做了一个晚上的题目,晕了View Code #include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;const double eps=1e-9;#define zero(x) (((x)>0? (x):-(x))<eps)struct point{ double x,y;}a[1010];int n,s[1010];int top;int cmp(point a,point b){ if(a.y==b.y) re Read More
posted @ 2011-10-05 21:24 Because Of You Views(314) Comments(0) Diggs(0) Edit
还是太粗心了阿,求直线上的点到两点间距离和的最小值搞了好久阿,A点和B点有可能在直线的同侧也可能在异侧View Code #include<stdio.h>#include<math.h>const double eps = 1e-9;struct point{ double x,y;}A,B,C,A1,node;double dis(point a,point b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}double cross(point a,point b,point c){ return ( Read More
posted @ 2011-10-05 16:52 Because Of You Views(316) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<stdlib.h>__int64 exgcd(__int64 a,__int64 b,__int64 &x,__int64 &y){ if(b==0) {x=1;y=0;return a;} else { __int64 d=exgcd(b,a%b,x,y); __int64 t=x; x=y; y=t-a/b*y; return d; }}int main(){ __int64 a,b,x,y; while(sca... Read More
posted @ 2011-10-05 02:01 Because Of You Views(196) Comments(0) Diggs(0) Edit
View Code #pragma warning (disable : 4786)#include<stdio.h>#include<map>#include<string>#include<iostream>using namespace std;int main(){ char str[50]; double num=0; map<string,int> M; while(gets(str)!=NULL) { M[str]++; num++; } map<string,int>::iterator it; for.. Read More
posted @ 2011-10-04 21:54 Because Of You Views(224) Comments(0) Diggs(0) Edit
一觉醒来,不觉已经是4点了,于是果断挑了一道水题。View Code #include<stdio.h>#include<string.h>#include <cctype>char str[5000];int main(){ int i,j,k; while(gets(str)) { char s[]="0000"; int len=strlen(str); int row=len/16; int left=len%16; int a=0; for(i=0;i<row;i++) ... Read More
posted @ 2011-10-02 18:01 Because Of You Views(232) Comments(0) Diggs(0) Edit
仔细想想后发现其实只要求出各个面面积的大小即可。easy~ Read More
posted @ 2011-10-01 10:40 Because Of You Views(149) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<string.h>#define max 100010 int b[max],c[max];__int64 x[max],y[max];int a[max];int lowbit(int x){ return x&(-x);}void update(int arr[],int x){ while(x<=max) { arr[x]++; x+=lowbit(x); }}__int64 sum(int arr[],int x){ __int64 ans=0; wh... Read More
posted @ 2011-09-29 17:15 Because Of You Views(285) Comments(0) Diggs(0) Edit