摘要:
题意: 给你一组数,让你求他的逆序数。分析: 数子比较大,直接用数组存不下,所以要进行离散话坐标。View Code #include<stdio.h>#include<string.h>#include<stdlib.h>struct node{ int xu; int num;}q[500001];int cmp(const void*p1,const void*p2){ struct node*c=(struct node*)p1; struct node*d=(struct node*)p2; return c->num-d->num;} 阅读全文
posted @ 2012-05-03 21:15
'wind
阅读(181)
评论(0)
推荐(0)
摘要:
题意: 让你找出1 到 n 之间所有可以构成 x^2 +y^2 =z^2 的个数,且 x,y,z互质。分析:数论中有本原勾股数组的公式x=2*s*t,y=s*s-t*t,z=s*s+t*t;其中s>t>=1而且gcd(s,t)==1View Code #include<stdio.h>#include<string.h>#include<math.h>int gcd(int y,int x){ return x==0?y:gcd(x,y%x);}int v[1000001];int main(){ int n,x,y,z,t1,t2,i,j,k; 阅读全文
posted @ 2012-05-03 20:09
'wind
阅读(260)
评论(0)
推荐(0)


浙公网安备 33010602011771号