biying

导航

2013年4月19日 #

快排模板

摘要: 快速排序-6类qsort排序以下是其具体分类及用法(若无具体说明是以降序排列):1、对一维数组排序:(Element_type是一位数组中存放的数据类型,可以是char, int, float, double, etc )使用qsort之前,必须自己定义一个比较函数。这个比较函数用于比较两个元素的大小。由于qsort可以排序任意数据类型,包括自定义的结构类型,因此,做一个自定义的比较函数是必要的。int Comp(const void *p1,const void *p2 ){ return *((Element_type *)p2) > *((Element_type *)p1) ? 阅读全文

posted @ 2013-04-19 21:56 biying 阅读(223) 评论(0) 推荐(0) 编辑

2013年4月18日 #

hdu1232简单并差集(2)

摘要: View Code 1 #include<stdio.h> 2 int father[1005]; 3 int findset(int x) 4 { 5 return x==father[x]?x:(father[x]=findset(father[x])); 6 } 7 int main() 8 { 9 int n,m,i,a,b,x,y,k;10 while(scanf("%d %d",&n,&m)&&n)11 {12 13 for(i=1;i<=n;i++)14 {15 father[i]=i;16... 阅读全文

posted @ 2013-04-18 21:27 biying 阅读(133) 评论(0) 推荐(0) 编辑

hdu1213简单并差集

摘要: 第一次做并差集,算是留个纪念吧~~View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <algorithm> 5 using namespace std; 6 const int MAXN = 1010; 7 int M, N; 8 int parent[MAXN]; 9 10 int myfind(int i) {11 int r = i;12 while (parent[r] != r) {13 r = parent[r];14 阅读全文

posted @ 2013-04-18 21:02 biying 阅读(143) 评论(0) 推荐(0) 编辑

2013年4月14日 #

poj1035 数据结构串(1)

摘要: 输入一部字典,输入若干单词1、 若某个单词能在字典中找到,则输出corret2、 若某个单词能通过 变换 或 删除 或 添加一个字符后,在字典中找得到,则输出这些单词,输出顺序根据 输入的那部字典的字典序3、 若某个单词无论操作与否都无法在字典中找得到,则输出空View Code 1 //Memory Time 2 //456K 157MS 3 4 #include<iostream> 5 #include<string.h> 6 using namespace std; 7 8 char dict[10001][16]; 9 char word[51][16]; 1. 阅读全文

posted @ 2013-04-14 21:03 biying 阅读(218) 评论(0) 推荐(0) 编辑

2013年4月13日 #

各种切割(数学)

摘要: 包含直线,v型线,椭圆,三角形分割问题(1) n条直线最多分平面问题(hdu1290)题目大致如:n条直线,最多可以把平面分为多少个区域。析:可能你以前就见过这题目,这充其量是一道初中的思考题。但一个类型的题目还是从简单的入手,才容易发现规律。当有n-1条直线时,平面最多被分成了f(n-1)个区域。则第n条直线要是切成的区域数最多,就必须与每条直线相交且不能有同一交点。 这样就会得到n-1个交点。这些交点将第n条直线分为2条射线和n-2条线断。而每条射线和线断将以有的区域一分为二。这样就多出了2+(n-2)个区域。故:f(n)=f(n-1)+n=f(n-2)+(n-1)+n……=f(1)+1+ 阅读全文

posted @ 2013-04-13 18:43 biying 阅读(376) 评论(0) 推荐(0) 编辑

Fibonacci性质 hdu1568

摘要: 先看对数的性质,loga(b^c)=c*loga(b),loga(b*c)=loga(b)+loga(c);假设给出一个数10234432,那么log10(10234432)=log10(1.0234432*10^7)=log10(1.0234432)+7;log10(1.0234432)就是log10(10234432)的小数部分.log10(1.0234432)=0.01006374410^0.010063744=1.023443198那么要取几位就很明显了吧~先取对数(对10取),然后得到结果的小数部分bit,pow(10.0,bit)以后如果答案还是<1000那么就一直乘10。注 阅读全文

posted @ 2013-04-13 18:39 biying 阅读(188) 评论(0) 推荐(0) 编辑

大数模板

摘要: View Code 1 #include<iostream> 2 #include<string> 3 #include<iomanip> 4 #include<algorithm> 5 using namespace std; 6 7 #define MAXN 9999 8 #define MAXSIZE 10 9 #define DLEN 4 10 11 class BigNum 12 { 13 private: 14 int a[500]; //可以控制大数的位数 ... 阅读全文

posted @ 2013-04-13 09:37 biying 阅读(426) 评论(0) 推荐(0) 编辑