hdu 1757【A Simple Math Problem】
摘要:矩阵相乘代码如下: 1 #include <cstdio> 2 #include <cstring> 3 4 struct matrix 5 { 6 int g[10][10]; 7 }mt; 8 9 int kk,m;10 11 matrix multi(matrix a,matrix b)12 {13 matrix ans;14 15 for(int i = 0;i < 10;i ++)16 {17 for(int j = 0;j < 10;j ++)18 {19 int t = 0;20 ...
阅读全文
posted @
2012-05-25 21:24
Shirlies
阅读(194)
推荐(0) 编辑
hdu 2824【The Euler function】
摘要:代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 5 const int maxn = 3000000+100; 6 int phi[maxn]; 7 int a,b; 8 9 void phi_table(int n)10 {11 memset(phi,0,sizeof(phi));12 phi[1] = 1;13 for(int i = 2;i <= n;i ++)14 {15 if(!phi[i])16 {17 ...
阅读全文
posted @
2012-05-23 18:00
Shirlies
阅读(166)
推荐(0) 编辑
hdu 2768【Cat vs. Dog】
摘要:代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 using namespace std; 5 6 struct node 7 { 8 char cc[7],dd[7]; 9 }cat[1000],dog[1000];10 11 vector<int> match[1000];12 int vis[1000];13 int link[1000];14 int n,m,k;15 16 bool can(int x)17 {18 int len = match[x
阅读全文
posted @
2012-05-23 12:49
Shirlies
阅读(229)
推荐(0) 编辑
hdu 1281【棋盘游戏】
摘要:代码如下: 1 #include <cstdio> 2 #include <cstring> 3 4 int n,m,k; 5 int g[110][110]; 6 int link[110]; 7 int a[10000],b[10000]; 8 int vis[110]; 9 10 bool can(int x)11 {12 for(int i = 1;i <= m;i ++)13 {14 if(g[x][i] && !vis[i])15 {16 vis[i] = 1;17 if(link[i...
阅读全文
posted @
2012-05-23 12:45
Shirlies
阅读(236)
推荐(0) 编辑
hdu 1348【wall】
摘要:晕死,一个循环害死我了,改了好长时间一直WA,搞得我莫名其妙,真是百思不得其解,现在才发现时一个while写成了if,晕死~~~代码如下: 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4 using namespace std; 5 6 const double pi = acos(-1.0); 7 struct node 8 { 9 int x,y;10 }p[1100],stack[1100];11 12 int n;13 double length;14 int top;1
阅读全文
posted @
2012-05-22 21:38
Shirlies
阅读(311)
推荐(0) 编辑
hdu 1147【Pick-up sticks】
摘要:判断线段相交问题,其实还以为会超时的,结果良好^_^代码如下: 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4 5 struct point 6 { 7 double x,y; 8 }; 9 10 struct node11 {12 point aa,bb;13 }segment[100100];14 15 int n;16 int stack[100100];17 18 double cross_product(point &a,point &b,point &
阅读全文
posted @
2012-05-21 15:10
Shirlies
阅读(228)
推荐(1) 编辑
hdu 1577【WisKey的眼神】
摘要:代码如下: 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4 5 void solve(); 6 int L,sx,sy,px,py; 7 8 int main() 9 {10 while(scanf("%d",&L),L)11 {12 scanf("%d%d%d%d",&sx,&sy,&px,&py);13 14 if(py > L || px > L || py < -L || p
阅读全文
posted @
2012-05-20 21:44
Shirlies
阅读(310)
推荐(0) 编辑
hdu 1392【Surround the Trees】
摘要:凸包代码如下: 1 #include <cstdio> 2 #include <algorithm> 3 #include <cstring> 4 #include <cmath> 5 using namespace std; 6 7 struct node 8 { 9 int x,y;10 }p[1000],stack[1000];11 int n,top;12 13 double dis(node &a,node &b)14 {15 return sqrt(1.0*(a.x - b.x) * (a.x - b.x) + 1.0
阅读全文
posted @
2012-05-20 21:35
Shirlies
阅读(172)
推荐(0) 编辑
hdu 1507【Uncle Tom's Inherited Land*】
摘要:#include <cstdio>#include <cstring>#include <vector>using namespace std;vector<int> land[100];int link[100];bool vis[100];int g[110][110];bool vis2[100];int pond[100];int n,m,k;bool can(int x){ int len = land[x].size(); for(int i = 0;i < len;i ++) { int t = land[x].at(i);
阅读全文
posted @
2012-05-13 11:24
Shirlies
阅读(306)
推荐(0) 编辑
hdu 1528【Card Game Cheater】
摘要:#include <iostream>#include <cstring>#include <string>#include <vector>using namespace std;vector<int> card[100];int n;bool vis[100];int link[100];int num_pre(char a){ static string pre = "23456789TJQKA"; for(int i = 0;i < pre.size();i ++) { if(a == pre.at(
阅读全文
posted @
2012-05-13 09:40
Shirlies
阅读(412)
推荐(0) 编辑
hdu 2819【Swap】
摘要:不错的一道题目,但是中途我还是出问题了,代码中有注释代码如下: 1 #include <cstdio> 2 #include <cstring> 3 4 struct node 5 { 6 int x,y; 7 }ans[1005]; 8 9 int g[200][200];10 bool vis[200];11 int link[200];12 int match[200];13 int n;14 15 void init()16 {17 memset(link, -1,sizeof(link));18 }19 20 bool can(int x)21 {22 f..
阅读全文
posted @
2012-05-11 15:47
Shirlies
阅读(266)
推荐(0) 编辑
hdu 1150【Machine Schedule】
摘要:有时候都不太想写博客了,(~ o ~)~zZ这一题是纯粹的二分图匹配,不过要注意一点哈“At the beginning they are both work at mode_0”,所以要判断一下两点连接的时候是不是存在0这个点if(a && b)pro[a].push_back(b);代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 using namespace std; 5 6 int vis[200]; 7 int link[200]; 8 vec
阅读全文
posted @
2012-05-10 13:19
Shirlies
阅读(217)
推荐(0) 编辑
uva 10330【 Power Transmission】
摘要:第一道网络流的题目,我是看这个讲解的http://www.nocow.cn/index.php/%E7%BD%91%E7%BB%9C%E6%B5%81Edmonds-Karp 算法主要是顶点有值限制,所以可以将一个点分成两个点a和a',它们两个之间的容量就是顶点的值代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 6 const int maxn = 300; 7 const int inf = 0x7fffffff;
阅读全文
posted @
2012-05-10 00:14
Shirlies
阅读(277)
推荐(0) 编辑
hdu 2722【Here We Go(relians) Again】
摘要:表示很无语的一题,纯粹意义上的字符处理,晕...用优先队列做的,时间0ms...代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 6 struct node 7 { 8 int u,v; 9 int w; 10 }p[5000]; 11 int d[1000]; 12 int n,m; 13 int num; 14 int first[5000]; 15 int nextt[5000]; 16 typedef pair<i
阅读全文
posted @
2012-05-04 21:13
Shirlies
阅读(344)
推荐(0) 编辑
hdu 2680
摘要:心血来潮,用优先队列实现了这个Dijkstra,顺便练练静态链表,不过结果也蛮不错的,在acm steps里面是93msA的,在外面却是109ms,排名很靠前,好开心,不过也郁闷,竟然有人31ms过了,汗...到底是怎么样的一个牛人啊......代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 using namespace std; 5 6 const int maxn = 20000 + 100; 7 int n,m,endd; 8 typedef pair<in
阅读全文
posted @
2012-05-02 20:44
Shirlies
阅读(287)
推荐(0) 编辑
hdu 1874【畅通工程续】
摘要:在此郑重的向南柯小朋友表示我的感谢!!如果不是他告诉我输入的时候需要处理if(g[a][b] == -1 || g[a][b] > w)g[a][b] = g[b][a] = w;(从一个点到另外一个点竟然有好几种选择,囧,我们仅仅需要考虑最小的就ok了)这个东西的话,相信我是找不出问题来的.......也向他表示感谢HDU today这一题也是他找出了问题,就是起点和目的地相同的情况我没有考虑......代码如下: 1 #include <cstdio> 2 #include <cstring> 3 4 int g[200][200]; 5 int vis[20
阅读全文
posted @
2012-05-02 18:29
Shirlies
阅读(155)
推荐(0) 编辑