摘要: 设平面上的点按x排序好了,这样最多增加O(N*logN),这再整个算法来看并没有增加复杂度级别。 排好序后,可以划一条垂线,把点集分成两半:PL和PR。于是最近点对或者在PL中,或者在PR中,或者PL,PR各有一点。 把三种距离情况定义为dL, dR, dC. 其中dL, dR可以递归求解,于是问题就变为计算dC。 根据上... 阅读全文
posted @ 2013-03-03 08:39 码代码的猿猿 阅读(391) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;int main(){ int n; cin>>n; while(n!=0) { int sum=n*5,k; int sig=0; for(int i=0;i>k; if(k-sig>0) sum+=(k-sig)*6; ... 阅读全文
posted @ 2013-03-03 07:01 码代码的猿猿 阅读(106) 评论(0) 推荐(0) 编辑
摘要: HDOJ 1089:#include using namespace std;int main(){ int a,b; while(cin>>a>>b) { coutusing namespace std;int main(){ int a,b; int c; cin>>c; for(int i=0;i>a>>b; coutus... 阅读全文
posted @ 2013-03-02 06:18 码代码的猿猿 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 如果直接按秒模拟的话,结果精度不够!但可以按1/10秒模拟,精度就够了,但是会超时! #include #include #include #define MT (12*36000)using namespace std;int isD(double a,double b,int D){ double k=fabs(a-b); if(k=D) return 1; } e... 阅读全文
posted @ 2013-03-02 05:12 码代码的猿猿 阅读(408) 评论(0) 推荐(0) 编辑
摘要: 以下来自:http://www.cnblogs.com/krisdy/archive/2009/04/12/1434013.html1、必然会出现循环这是基于下面事实:1. R(n+2)=F(n+2) mod P=(F(n+1)+F(n)) mod P=(F(n+1) mod p +F(n) modp) mod p2. 斐波那契数列的最大公约数定理:gcd(F(m),F(n))=F(gcd(m,n... 阅读全文
posted @ 2013-03-01 08:03 码代码的猿猿 阅读(509) 评论(0) 推荐(0) 编辑
摘要: #include#include#includeusing namespace std; int c[1001]; string color; string real_color[1001];int main(){ int n; cin>>n;while(n!=0){ int real_n=0; int max=0; int pos=-1; m... 阅读全文
posted @ 2013-03-01 05:57 码代码的猿猿 阅读(78) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;int arr[100010];int main(){int l;cin>>l;for(int j=0;j>n; for(int i=0;i>arr; int t=0,beginpos,endpos,max=-99999999,k=0; for(int i=0;imax) { max=t... 阅读全文
posted @ 2013-02-28 07:46 码代码的猿猿 阅读(114) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;char s1[1100];char s2[1100];int a[1100];int b[1100];int sum[1100];int main(){ int loop; cin>>loop;for(int lbs=0;lbs>s1>>s2; for(i=0;s1!='\0';i++) ... 阅读全文
posted @ 2013-02-28 04:55 码代码的猿猿 阅读(131) 评论(0) 推荐(0) 编辑
摘要: #include #include #define MAXN 40000using namespace std;int a[MAXN];int main(){ int n; while(cin>>n) { memset(a,0,sizeof(a)); a[0]=1; int i,j; for(i=2;i=0;i--) ... 阅读全文
posted @ 2013-02-27 06:58 码代码的猿猿 阅读(111) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std;int main(){ int a,b; while(cin>>a>>b) cout<<a+b<<endl; return 0;} 阅读全文
posted @ 2013-02-27 06:56 码代码的猿猿 阅读(113) 评论(0) 推荐(0) 编辑