摘要: 1、已知每个行星的角速度为wi= 2*π/Ti选择一个行星T0作为坐标系,则其他行星的相对速度为wi' = wi-w0;则角度绕过半个圆周的时间为Ti' =π/wi' = (T0*Ti)/( (T0 - Ti)*2 ),如果要求两行星在一条直线上的最短时间,必然满足该公式2、要求多个分数的最小公倍数,得到的分数的分子必须是所有分母的最小公倍数,得到的分母是所有分子的最大公约数。#include #include #include #include #define N 10001using namespace std;int gcd(int a,int b){ retur 阅读全文
posted @ 2014-01-27 14:12 单调的幸福 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 文章要点:Gregorian Calendar格里高公历 就是现在广泛使用公历(西历),下面简称GCGC的起始日期为 1年1月1号,该日为星期六GC平年有365天,闰年366天(2月多1天)GC有12个月,各月的天数和现在的使用的西历一致GC在1582年之前(不包括1582),若该年份能被4整除,则为闰年GC在1582年之后(包括1582),判断闰年的标准(满足下面随便一个):(1) 能被4整除,但不能被100整除;(2) 能被400整除。由于历史原因,GC规定1700年无条件为闰年由于历史原因,GC规定1752年9月3日~13日共11天不存在,即1752年9月只有19天#include in 阅读全文
posted @ 2014-01-25 14:05 单调的幸福 阅读(260) 评论(0) 推荐(0) 编辑
摘要: # include# include#includeusing namespace std;# define maxn 2005char s[maxn];int dp[maxn][maxn],cost[maxn];int main(){ int n,m,a,b,i,j; char temp; while(scanf("%d%d",&n,&m)!=EOF) { memset(dp,0,sizeof(dp)); getchar(); scanf("%s",s+1); getchar(); for(i=1;... 阅读全文
posted @ 2014-01-24 10:28 单调的幸福 阅读(166) 评论(0) 推荐(0) 编辑
摘要: #include #include #define MAX 32010int lev[MAX],c[MAX];int Lowbit(int x){ return x & (-x);}void Updata(int x){ while( x 0 ) { sum += c[x]; x -= Lowbit(x); } return sum;}int main(){ int n,x,y,i; while( ~scanf("%d",&n) ) { memset(lev,0,sizeof(lev)); memset(c,0,sizeof(c)); for(i=1; i& 阅读全文
posted @ 2014-01-23 21:16 单调的幸福 阅读(131) 评论(0) 推荐(0) 编辑
摘要: #include const int INF = 99999999 ;int cnt,m ,n ,dist[15010] ;structnode{ int u,v,w ;}edge[10700700] ;void addedge(int u,int v,int w){ edge[cnt].u = u ; edge[cnt].v = v ; edge[cnt].w = w ; cnt++ ;}bool bellman_ford(int start){ for(int i = 1 ; i dist[u] + w) { ... 阅读全文
posted @ 2014-01-23 19:29 单调的幸福 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 01分数规划,sort+二分即可。注意精度问题,这种四舍五入的问题一般都是两种处理方法:1、printf("%.0lf\n",ans); 2、printf("%d\n",(int)(ans+0.5));#include#include#include#includeusing namespace std;#define N 1010double a[N],b[N],c[N];int n,K;int main(){ int i; double left,right,mid,sum; while(scanf("%d%d",&n,& 阅读全文
posted @ 2014-01-23 18:08 单调的幸福 阅读(243) 评论(0) 推荐(0) 编辑
摘要: Polya定理: 设G是一个p个对象的置换群,那么用k种颜色对p个对象进行染色!当一种方案在群G的作用下变为另外一种方案,那么我们这个时候就认为这两个方案是一样的。那么在这种规定下不同的染色方案为:n=(Ek^m(f))/|G|,其中m(f)是置换f的循环节。 Polya定理是基于Burnside定理和另外一个定理的,其中Burnside定理的通俗表达方法如下: 1)如果令C(f)表示在置换f的作用下,本质不变的着色方案数!那么可以证明的是“本质不同的着色方案数就是所有置换f下的C(f)的平均数”。 在Burnside的基础上,我们在介绍一个定理: 2)如果使用k种颜色给有... 阅读全文
posted @ 2014-01-23 14:28 单调的幸福 阅读(193) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;char map[15][20];int ansr,ansc,ansb,q[170][2],head,tail;char anscol;bool vis[15][20];const int move[4][2] = {{-1,0},{1,0},{0,1},{0,-1}};int area(int x,int y){ head = tail = 0; q[++tail][0] = x; q[tail][1] = y; char col = map[x][y]; int size = 0,... 阅读全文
posted @ 2014-01-23 12:09 单调的幸福 阅读(180) 评论(0) 推荐(0) 编辑
摘要: #include #include #include void loop(int *ans, char *lpNum){ char s[10], loopNum[10] = {0}; int i,x; while(scanf("%s", s) && s[0] != 'E') { if(s[0] == 'L') { int *tmp = new int[11]; memset(tmp, 0, 11*sizeof(int)); scanf("%s", loopNum); ... 阅读全文
posted @ 2014-01-23 09:02 单调的幸福 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 是最小路径覆盖问题:最小路径覆盖=最小路径覆盖=|G|-最大匹配数#include#includeconst int maxn = 40*10+10;int maps[45][15],g[maxn][maxn],linker[maxn],vis[maxn],uN,vN;int dfs(int u){ for(int v = 1; v <= vN; v++) if(!vis[v] && g[u][v]) { vis[v] = 1; if(linker[v] == -1 || dfs(linker[v])) ... 阅读全文
posted @ 2014-01-22 18:50 单调的幸福 阅读(224) 评论(0) 推荐(0) 编辑