自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(60)
  • 收藏
  • 关注

转载 Astronomy

1、已知每个行星的角速度为wi= 2*π/Ti选择一个行星T0作为坐标系,则其他行星的相对速度为wi' = wi-w0;则角度绕过半个圆周的时间为Ti' =π/wi' = (T0*Ti)/( (T0 - Ti)*2 ),如果要求两行星在一条直线上的最短时间,必然满足该公式2、要求多个分数的最小公倍数,得到的分数的分子必须是所有分母的最小公倍数,得到的分母是所有分子的最大公约...

2014-01-27 14:12:00 115

转载 Lucky and Good Months by Gregorian Calendar (模拟)

文章要点:Gregorian Calendar格里高公历 就是现在广泛使用公历(西历),下面简称GCGC的起始日期为 1年1月1号,该日为星期六GC平年有365天,闰年366天(2月多1天)GC有12个月,各月的天数和现在的使用的西历一致GC在1582年之前(不包括1582),若该年份能被4整除,则为闰年GC在1582年之后(包括1582),判断闰年的标准(满足下...

2014-01-25 14:05:00 205

转载 Cheapest Palindrome (DP,LCS)

# include<stdio.h># include<string.h>#include<algorithm>using namespace std;# define maxn 2005char s[maxn];int dp[maxn][maxn],cost[maxn];int main(){ int n,m...

2014-01-24 10:28:00 98

转载 stars(树状数组)

#include <stdio.h>#include <string.h>#define MAX 32010int lev[MAX],c[MAX];int Lowbit(int x){ return x & (-x);}void Updata(int x){ while( x < MAX ) { c[...

2014-01-23 21:16:00 93

转载 Is the Information Reliable?(差分约束)

#include <stdio.h>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 ; ...

2014-01-23 19:29:00 89

转载 Dropping tests

01分数规划,sort+二分即可。注意精度问题,这种四舍五入的问题一般都是两种处理方法:1、printf("%.0lf\n",ans); 2、printf("%d\n",(int)(ans+0.5));#include<cstring>#include<cstdio>#include<cmath>#include<algorit...

2014-01-23 18:08:00 89

转载 Necklace of Beads(polya)

Polya定理: 设G是一个p个对象的置换群,那么用k种颜色对p个对象进行染色!当一种方案在群G的作用下变为另外一种方案,那么我们这个时候就认为这两个方案是一样的。那么在这种规定下不同的染色方案为:n=(Ek^m(f))/|G|,其中m(f)是置换f的循环节。 Polya定理是基于Burnside定理和另外一个定理的,其中Burnside定理的通俗表达...

2014-01-23 14:28:00 154

转载 The Same Game(模拟)

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;char map[15][20];int ansr,ansc,ansb,q[170][2],head,tail;char anscol;bool vis[15][20];c...

2014-01-23 12:09:00 147

转载 Instant Complexity (模拟)

#include <stdio.h>#include <string.h>#include <stdlib.h>void loop(int *ans, char *lpNum){ char s[10], loopNum[10] = {0}; int i,x; while(scanf("%s", s) &am...

2014-01-23 09:02:00 68

转载 poj Antenna Placement(二分图的匹配)

是最小路径覆盖问题:最小路径覆盖=最小路径覆盖=|G|-最大匹配数#include<stdio.h>#include<string.h>const int maxn = 40*10+10;int maps[45][15],g[maxn][maxn],linker[maxn],vis[maxn],uN,vN;int dfs(int u){ ...

2014-01-22 18:50:00 42

转载 poj Monthly Expense(二分)

#include <stdio.h>#include <string.h>#include <math.h>int a[100010],l,r,n,m;int check(int mon){ int i=1,j,s; for(j=0,s=0;j<=n-1;j++) if((s+a[j])&...

2014-01-22 18:40:00 56

转载 poj paid road(DFS)

#include <stdio.h>#include <string.h>int N,m;structnode{ int a,b; int ci,pi,ri;}maps[20];int minS,flag[11];void dfs(int pos,int res){ if(pos==N) {...

2014-01-21 21:30:00 74

转载 炮兵阵地(状态压缩dp)

#include<algorithm>#include<cstdio>#include<cstring>using namespace std;int R,C,dp[110][70][70],stk[70],top,cur[110],num[110];char s[110][20];bool fit(int x,int k) ...

2014-01-21 19:23:00 132

转载 poj Fibonacci(快速幂取模运算)

快速幂参考的百度文库的一个文章,写的很详细http://wenku.baidu.com/view/2384ecc02cc58bd63186bdf6.html#include<cstdio>#include<cstring>void Mul(int a[2][2],int b[2][2],int c[2][2]){ int i,j,k,sum...

2014-01-21 17:59:00 88

转载 Surprising Strings(map)

#include<string.h>#include<string>#include<map>#include<stdio.h>using namespace std;int main(){ int i,d; char s[80]; while(scanf("%s",s)!=EOF &&am...

2014-01-21 16:55:00 53

转载 poj sumdiv(数学)

将a进行质因数分解,则 a=(p1^k1)*(p2^k2)*...*(pn^kn); 故 a^b= p1^(a1*B) * p2^(a2*B) *...* pn^(an*B);根据公式,所有因子之和为sum=(1+p1+p1^2+...p1^k1)*(1+p2+p2^2+...p2^k2)*...*(1+pn+pn^2+...+pn^kn)计算1+...

2014-01-21 10:41:00 132

转载 Paths on a Grid (数学)

#include <stdio.h>__int64 C(__int64 a,__int64 b){if(b==0)return 1;else if(b==1)return a;elsereturn C(a-1,b-1)*a/b;}int main(){__int64 n,m;while(s...

2014-01-21 08:28:00 87

转载 Round Numbers(数学)

#include<iostream>#include<cstdio>using namespace std;int c[35][35];void Init(){ int i,j; for(i=0;i<33;i++) { c[i][0]=c[i][i]=1; for(j=1;...

2014-01-20 20:27:00 78

转载 Channel Allocation(DFS着色问题)

#include <cstdio>#include <cstring>int T,grid[30][30],color[30],ret[30];void dfs(int x){ int c[30]={0},i; for (i=0;i<T;i++) if (grid[x][i]) ...

2014-01-20 18:14:00 115

转载 poj Shredding Company(DFS)

strncpy可以替代strcpy来防止缓冲区越界。但是如果还要考虑运行效率的话,也许strlcpy是一个更好的方式。1. strcpy我们知道,strcpy 是依据 /0 作为结束判断的,如果 to 的空间不够,则会引起 buffer overflow。strcpy 常规的实现代码如下(来自 OpenBSD 3.9):char *strcpy(char *to, const...

2014-01-17 11:52:00 78

转载 poj Number Sequence(数学)

计算一个十进制数的位数 (int)log10((double)i) + 1#include <stdio.h>#include <cmath>unsigned int a[32000], s[32000];void table(){ int i; a[1] = 1; s[1] = 1; for(i ...

2014-01-17 11:26:00 212

转载 poj Shuffle'm Up (map + 模拟)

Map是标准关联式容器(associativecontainer)之一,一个map是一个键值对序列,即(key ,value)对,Key - value的对应。key 和 value可以是任意你需要的类型。。它提供基于key的快速检索能力,在一个map中key值是唯一的。map提供双向迭代器,即有从前往后的(iterator),也有从后往前的(reverse_iterator)。m...

2014-01-16 16:54:00 66

转载 poj Spell checker

#include <cstdio>#include <cstring>char dic[10005][20];int t;int del(char a[],char b[]){ int i; for(i=0;a[i];i++) if(a[i]!=b[i]) break; ...

2014-01-15 18:56:00 92

转载 poj Squares(stl 二分查找 + sort)

#include <algorithm>#include <cstdio>using namespace std;structnode{ int x, y;} p[1005];bool Greater(const structnode &a, const structnode &b){ if (a.x == b....

2014-01-15 17:58:00 74

转载 poj Ultra-QuickSort(归并排序)

#include <stdio.h>#define N 500005using namespace std;int a[N],a1[N];__int64 time; //范围为 -2^63 (-9,223,372,036,854,775,808) 到 2^63-1 (9,223,372,036,854,775,807),存储空间占 8 字节。void...

2014-01-15 12:56:00 31

转载 All in All (字符串匹配)

#include <stdio.h>#include <string.h>#define N 100005char str1[N],str2[N];int main(){ int i,j,len1,len2; while(scanf("%s %s",str1,str2)!=EOF) { j=0;...

2014-01-14 11:23:00 123

转载 Borg Maze (bfs ,最小生成树)

#include <stdio.h>#include <string.h>#include <queue>#define N 105#define INF 1000000000using namespace std;structnode{ int x,y;};node dir[4]={{-1,0},{1...

2014-01-13 21:55:00 52

转载 Sorting It All Out(拓扑排序,floyd)

#include <stdio.h>#include <string.h>int map[28][28],num,n;char output[28];int Floyd(){ int i,k,j; for(i=1;i<=n;i++) for(k=1;k<=n;k++) for(j=1;j<=n;j++)...

2014-01-13 13:18:00 111

转载 Asteroids (匈牙利)

二分图的最小覆盖=最大匹配这是为什么呢?让我们来分析一下,这里有一个很好的模拟过程:将右边未匹配上的点依次加标记,然后标记左边与右边标记的相连的点,左边的点一定是最大匹配上的点,不然找到的一定不是最大匹配,标记最大匹配且左边已经标记了的点。最后取左边标记了的点和右边未标记的点就组成了最小覆盖。现在最大匹配的点一定都覆盖了,左边是最大匹配,...

2013-12-25 15:38:00 43

转载 Agri-Net (kruscal)

#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int parent[5000],n,ans;structnode{ int from,to,weight;}grid[5000];bool com_grea...

2013-12-22 17:42:00 95

转载 Stockbroker Grapevine (floyd)

1A#include <stdio.h>#include <string.h>#include <algorithm>#define INF 0x3f3f3f3fusing namespace std;int grid[105][205],dist[105][205],n,p;int floyd(){ int...

2013-12-18 18:27:00 45

转载 Highways (最小生成树)

#include <stdio.h>#include <string.h>#include <algorithm>#define INF 0x3f3f3f3fusing namespace std;int grid[505][505],dist[505],visit[505],n;int prime(){ int ...

2013-12-17 11:31:00 73

转载 Truck History (最小生成树)

prim或kruscal都可以#include <stdio.h>#include <string.h>#include <math.h>#include <algorithm>#define INF 0x3f3f3f3fusing namespace std;char g[2005][8];int grid...

2013-12-17 10:54:00 83

转载 Frogger (Dijkstra)

#include <stdio.h>#include <string.h>#include <math.h>#include <algorithm>#define INF 0x3f3f3f3fusing namespace std;double dist[201],grid[201][201];int visit...

2013-12-16 21:12:00 64

转载 Wormholes (bellman)

求负环自然要用 belllman#include <stdio.h>#include <string.h>int F,n,m,w,p,dist[501];structnode{ int s,e,t;}grid[5500];int bellman(){ int i,k; memset (dist,0,si...

2013-12-15 20:52:00 128

转载 Currency Exchange (bellman)

Bellman-ford算法N次迭代就可以判断图中是否有“负环”。#include <stdio.h>#include <string.h>int n,m,s;double d[100],v;structnode{ int a,b; double rate,com;}g[200];int bellman() ...

2013-12-13 21:49:00 75

转载 昂贵的聘礼 (dijkstra)

#include<stdio.h>#include<cstring>#define INF 0x3f3f3f3fint grid[102][102],dist[102],d[102],in[102],ans=INF,n,m;structnode{ int P,L,X;}g[102];int Dijkstra(){ ...

2013-12-12 22:08:00 57

转载 floyd Arbitrage(floyd) 1A水过

#include<stdio.h>#include<cstring>char a[35][100],b[100],c[100];int n;double grid[35][35];int exc(char str[100]){ for (int i=0;i<n;i++) if(strcmp(a[i],str...

2013-12-10 22:00:00 44

转载 Network Saboteur(dfs)

#include<stdio.h>int n,ans = 0,map[21][21],set[21];void dfs(int x, int sum){ int i,m; if(x>n) { if(sum > ans) ans = sum; return; ...

2013-12-10 20:04:00 43

转载 Sudoku(DFS)

#include<stdio.h>#include <cstring>int map[10][10],row[10][10],col[10][10],grid[10][10];int DFS(int x,int y){if(x==9)return 1;if(map[x][y]){if(y==8)return DFS(x+1,0);else...

2013-12-10 10:25:00 50

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除