View Code #include<stdio.h>#include<string.h>#define MAXN 101000#define INF 2000000struct NODE{ int v; int w; NODE *next;}edge[MAXN],redge[MAXN],temp[MAXN*2];int pos=0;int ecost[MAXN];int N,M,W,s,Q[MAXN];bool vis[MAXN];void spfa(int dir)//0为正向,1为反向{ int head,rear,u,i; NODE*ptr; hea... Read More
posted @ 2011-09-16 15:32 Because Of You Views(178) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<string.h>int prime[10000];int vis[10000];int ans;int a[10000];void init(){ int i,j; int n=12997; memset(vis,0,sizeof(vis)); for(i=2;i<=n;i++) for(j=i*2;j<=n;j+=i) vis[j]=1; ans=1; for(i=2;i<=n;i++) { if... Read More
posted @ 2011-09-14 15:27 Because Of You Views(238) Comments(0) Diggs(0) Edit
水题,不解释View Code #include<stdio.h>#include<string.h>const int INF = 9999999;int n,r,map[250][250];char city[250][30];int num;int max(int a,int b){ return a>b?a:b;}int min(int a,int b){ return a<b?a:b;}int find(char s[]){ int i; for(i=0;i<num;i++) if(strcmp(city[i],s)==0) ... Read More
posted @ 2011-09-14 14:48 Because Of You Views(139) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<math.h>#include<iostream>using namespace std;typedef __int64 lld;void gcd(lld a,lld b,lld &d,lld &x,lld &y){ if(!b) {d=a;x=1;y=0;} else { gcd(b,a%b,d,y,x);y-=x*(a/b);}}int main(){ lld x,y,m,n,l; lld a,b,c,d,g,s; scanf("%I64d%I64d Read More
posted @ 2011-09-12 20:50 Because Of You Views(229) Comments(0) Diggs(0) Edit
现在还不怎么适应比赛的节奏啊,二分边长即可,余弦定理求角度即可,注意,要先判断所选取的边是否合法View Code #include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>const double pi = acos(-1.0);const double expn=1e-8;double a[110];int n;double get_angel(double x,double y,double z){ return acos((x*x+y*y-z*z)/(2*x* Read More
posted @ 2011-09-12 15:28 Because Of You Views(261) Comments(0) Diggs(0) Edit
直接在矩阵上进行floyd在判断即可View Code #include<stdio.h>int map[110][110];int vis[110][110];int main(){ int t,n,i,j,k; int cases=1; scanf("%d",&t); while(t--) { scanf("%d",&n); int tot=n*(n-1); for(i=1;i<=n;i++) for(j=1;j<=n;j++) { scanf(... Read More
posted @ 2011-09-11 21:39 Because Of You Views(156) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<math.h>#include<string.h>struct PEAK{ double x,h;}p[1100];struct bit{ double x,v,m;}pat[1100];int main(){ int G=20; double h; int t,cases=1,i,j,n,m,w; scanf("%d",&t); while(t--) { double v0=0,temp; scanf("%d%d%d",&n,&a Read More
posted @ 2011-09-11 21:19 Because Of You Views(306) Comments(0) Diggs(0) Edit
View Code #include<stdio.h>#include<string.h>const int MAX=8010;#define L(x) x<<1#define R(x) x<<1|1#define MID(x,y) (x+y)>>1struct { int l,r,col;}node[MAX*4];int seg[MAX],col[MAX];void init(){ memset(node,0,sizeof(node)); memset(col,-1,sizeof(col));}void build(int t,in Read More
posted @ 2011-09-08 20:52 Because Of You Views(389) Comments(0) Diggs(1) Edit
View Code #include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#define maxn 1005const int inf =1000000000;struct Edge{ int u,v; __int64 cost;}E[maxn*maxn];int nv,ne;int pre[maxn],ID[maxn],vis[maxn];__int64 In[maxn];int ansi;//最小树形图邻接表版本,三步走,找最小入弧,找有向环,缩环为点__in Read More
posted @ 2011-09-07 12:54 Because Of You Views(991) Comments(0) Diggs(1) Edit
需要注意,因为增加一个零点,最后总点数要加1;此模板的边和点都从0开始计数废话一句,厚积方能薄发啊。View Code #include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#define maxn 1005const int inf =1000000000;struct Edge{ int s,t; int cost;}edge[maxn*maxn];struct node{ int x,y,z;}a[maxn];int E,nv,ne;int pre[maxn Read More
posted @ 2011-09-06 20:07 Because Of You Views(320) Comments(0) Diggs(0) Edit