自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

da_fan_shu_的专栏

Life, as long as you make full use of, it is the long-term.生命,只要你充分利用,它便是长久的。

  • 博客(123)
  • 资源 (2)
  • 收藏
  • 关注

转载 例题8.3.5

最大值最小化//目标学会用猜数字(二分)的方法,换个角度来解决问题 #include#include#includeconst int maxn=100000;int A[maxn],n,m,max;void input(){ scanf("%d%d",&n,&m); max=0; for(int i=0;i<n;i++) { sca

2012-12-05 21:41:01 437

原创 例题7.5.1

/* @title: 埃及分数 @method: 迭代加深搜索(DFID) @author: da_fan_shu_ @source: 算法竞赛入门经典例题7-2 @reference: http://www.docin.com/p-15271287.html */ #include#includeusing namespace std;const

2012-12-02 16:39:40 451

原创 poj 1456.Supermarket

Supermarket #include#include#include#includeusing namespace std;#define N 10010int pre[N];struct node{ int profit, deadline;}p[N];bool operator < (const node& a, const node

2012-11-28 21:28:59 305

原创 hdoj 1856.More is better

More is better#include#includeusing namespace std;const int MAXN=10000000+10;int n,father[MAXN],fatherson[MAXN];void init(){ for(int i=1;i<MAXN;i++){ father[i]=i; fatherson[i]=1;

2012-11-28 21:23:58 330

原创 hdoj 1213.How Many Tables

How Many Tables#include#includeusing namespace std;const int MAXN=1000+10;int n,father[MAXN];void init(){ for(int i=1;i<=n;i++){ father[i]=i; }}int getfather(int a){ int r;

2012-11-28 21:22:06 330

原创 zoj 3114.Double Queue

Double Queue#include#include#include using namespace std;int main(){ mapmp; map::iterator it; int r,k,p; while(scanf("%d",&r)&&r!=0){ if(r==1){ scanf("%d %d",&k,&p); mp[

2012-11-28 21:19:05 346

原创 poj 1002.487-3279

487-3279#include#include#include#includeusing namespace std;int main(){ int n; char c; string s; mapmp; map::iterator it; scanf("%d",&n); c=getchar(); for(int i=0;i<n;i++

2012-11-28 21:16:31 266

原创 例题7.4.4

带宽#include#include#include#define maxn 100 + 10#define set0(a) memset(a, 0, sizeof(a))int g[maxn][maxn], n, ne[maxn], min, vis[maxn], ans[maxn], best[maxn];void dfs(int cur, int found){

2012-11-27 15:10:20 427

原创 例题7.4.3

困难的串#includeusing namespace std;const int MAXN=80;int n,L,cnt;int S[MAXN]={0};int dfs(int cur){ if(cnt++==n){ for(int i=0;i<cur;i++){ printf("%c",'A'+S[i]); } return 0;

2012-11-27 14:48:24 353

原创 例题7.4.2

素数环#include#include#includeusing namespace std;const int MAXN=40;int isp[MAXN];int is_prime(int r){ int tmp=sqrt(r); for(int i=2;i<=tmp;i++){ if(r%i==0){ return 0; }

2012-11-26 13:54:46 273

原创 例题7.4.1

八皇后问题#include#includeusing namespace std;const int MAXN=100;int x[MAXN];int n,sum=0;int place(int k){ for(int j=0;j<k;j++){ if(abs(k-j)==abs(x[j]-x[k])||(x[j]==x[k])){ ret

2012-11-24 09:38:47 303

转载 NOIP2012复习提纲

NOIP2012复习提纲一、高精度计算a) 高精度加法b) 高精度减法c) 高精度乘法d) 高精度除以低精度e) 压位高精f) 二进制模拟高精度运算(见tyvj某模拟题第一题题解,用位运算)二、排序a) 选择排序b) 冒泡排序c) 插入排序d) 希尔排序e) 快速排序f) 堆排序g) 二叉树排序h) 基数排序i) 计数排序j)

2012-11-23 19:22:34 384

原创 poj 3895.Cycles of Lanes

Cycles of Lanes#include #include #include using namespace std;#define N 5000vector v[N];int vis[N];int step[N];int ans;void dfs(int x,int t){ vis[x]=1; step[x]=t

2012-11-22 21:08:08 253

原创 poj 1028.Web Navigation

Web Navigation#include#include#includeusing namespace std;#define ACM "http://www.acm.org/"int main(){ stack Forward; stack Backward; string str; Backward.push(ACM); while(c

2012-11-22 20:58:33 326

原创 poj 3032.Card Trick

Card Trick#include#include#includeusing namespace std;const int MAXN=250+10;queue q;int v[MAXN];int main(){ int m,n; cin>>m; while(m--){ cin>>n; for(int i=0;i<n;i++){

2012-11-22 20:56:01 361

原创 ural 1654. Cipher Message

Cipher Message#include#include#includeusing namespace std; const int MAXN=200000+10;stack stk;int main(){ char c; while((c=getchar())!='\n'){ if(!isalpha(c)) { continue;

2012-11-21 21:50:18 256

原创 ural 1126. Magnetic Storms

Magnetic Storms#include #include #include using namespace std; struct Node { int id,val; }; int main() { int n,ncase=1; Node node;

2012-11-21 21:47:28 328

原创 ural 1613. For Fans of Statistics

For Fans of Statistics#include#include#include#include#includeusing namespace std;const int MAXN = 70000+5;const int INF = 0x3f3f3f3f;int n, q, c[MAXN], d[MAXN], l, r, x;vector V[M

2012-11-21 21:30:57 291

原创 ural 1306. Sequence Median

Sequence Median#include#include #includeusing namespace std;int main(){ priority_queue pq; int n; int r; scanf("%d",&n); if(n%2){ for(int i=0;i<n/2+1;i++){ scanf("%d",&r

2012-11-21 21:26:30 231

原创 例题6.4.4

欧拉回路#include #include using namespace std;ifstream fin("in.txt");#define LEN 1001bool visited[LEN];bool arc[LEN][LEN];int degree[LEN];int n,m;void dfs(int v) //深度优先遍历

2012-11-20 21:12:18 268

转载 欧拉回路

经典七桥问题:对无向图:  定义:给定无孤立结点图G,若存在一条路,经过图中每条边一次且仅仅一次,该条路称欧拉路,若存在一条回路,经过图中每边一次且仅仅一次,该回路称为欧拉回路。具有欧拉回路的图称为欧拉图。定理:无向图G具有一条欧拉路,当且仅当G是连通的,且有0个或者是两个奇数度得结点。推论:无向图G具有一条欧拉回路,当且仅当G是连通的,并且所有结点的度数均为偶数。

2012-11-20 21:00:43 463

原创 例题6.4.3

拓扑排序#include#include#includeconst int MAXN=1000+10;int c[MAXN], n;int topo[MAXN], t;int G[MAXN][MAXN];bool dfs(int u){ c[u]=-1; for(int v=0;v<n;v++){ if(G[u][v]){ if(c

2012-11-20 17:54:53 368

转载 拓扑排序

一、概述  对一个有向无环图(Directed Acyclic Graph简称DAG)G进行拓扑排序,是将G中所有顶点排成一个线性序列,使得图中任意一对顶点u和v,若 ∈E(G),则u在线性序列中出现在v之前。    通常,这样的线性序列称为满足拓扑次序(TopoiSicai Order)的序列,简称拓扑序列。注意:    ①若将图中顶点按拓扑次序排成一行,则图中所有的有向边均是从

2012-11-20 16:15:34 291

原创 例题6.4.2

走迷宫#include#includeconst int MAXN=100+10;int n,m;char name[4]={'U','R','D','L'};int q[MAXN*MAXN],maze[MAXN][MAXN];int father[MAXN][MAXN],dist[MAXN][MAXN],vis[MAXN][MAXN];int dx[4]={0

2012-11-20 14:20:43 408

原创 例题6.4.1

黑白图像#include#include const int MAXN=256;int mat[MAXN][MAXN], vis[MAXN][MAXN];void dfs(int x,int y){ if(!mat[x][y]||vis[x][y]){ return; } vis[x][y]=1; dfs(x,y-1); dfs(x-1,y

2012-11-20 12:35:28 302

原创 例题6.3.3

二叉树重建#include#includechar s1[256],s2[256],ans[256];void build(int n,char* s1,char* s2,char* s){ if(n<=0){ return; } int p=strchr(s2,s1[0])-s2; build(p,s1+1,s2,s); build(n-p-

2012-11-20 12:13:11 248

原创 例题6.3.2

层次遍历#include #include #include using namespace std ; const int MAXN = 256 ; const int root = 1 ; int cnt , vis[MAXN] , val[MAXN] , Left[MAXN] , Right[MAXN] ; int NewN

2012-11-20 11:45:01 342

原创 例题6.3.1

小球下落#include#includeconst int MAXD=20;int s[1<<MAXD];int main(){ int D, I; while(scanf("%d%d",&D,&I)==2){ memset(s,0,sizeof(s)); int k, n=(1<<D)-1; for(int i=0;i<I;i++){

2012-11-19 13:21:02 556 1

原创 例题6.1.2

铁轨#includeconst int MAXN=1000+10;int n,target[MAXN];int main(){ while(scanf("%d",&n)==1){ int stk[MAXN], top=0; for(int i=1;i<=n;i++){ scanf("%d",&target[i]); } int A=1

2012-11-17 22:33:10 282

原创 例题6.1.1

卡片游戏#includeusing namespace std;#define MAX 100int n;int queue[MAX];//数组定义为2倍大小,否则读写非法内存 int begin;int end;void init(){ begin=0; for(int i=0;i<n;i++) { queue[i]=i+1; }

2012-11-16 00:38:23 280

原创 例题5.4.4

多少块土地#includeusing namespace std;int main(){int n;int V;int E;int F;while(cin>>n){ int sum1=0; for(int i=0;i<=n-2;i++) { sum1+=(i*(n-2-i)); } V=n+n*sum

2012-11-15 22:35:06 247

原创 例题5.4.3

果园里的树#include#includedouble doubleArea(double x0, double y0, double x1, double y1, double x2, double y2){ return fabs(x0*y1+x1*y2+x2*y0-x1*y0-x2*y1-x0*y2);} int main(){ double x0

2012-11-15 21:37:01 320

原创 例题5.4.2

因子和阶乘#include#includeint isPrime(int x){ for(int i=0;i*i<=x;i++){ if(x%i==0){ return 0; } } return 1;}int prime[100], count=0;int main(){ int n,p[100]; //构造一个

2012-11-15 20:14:26 233

原创 正整数高精度运算

加、减、乘、除#include#include//using namespace std;int Big(char* str1,char* str2);char* ClearFrontZero(char* str);void ToSameDigits(char* str1,char* str2);char* Plus(char* str1,char* s

2012-11-15 08:56:05 485

原创 例题5.4.1

Cantor的数表#includeint main(){ int n; while(scanf("%d",&n)==1){ int s=0,k=1; while(true){ s+=k; if(s>=n){ printf("%d/%d\n",s-n+1,k-s+n); break; } k++; } }

2012-11-15 08:40:01 208

原创 例题5.3.2

字母重排#include#include#includeint n;char word[2000][10], sorted[2000][10];//字符比较函数 int cmp_char(const void* _a, const void* _b){ char* a=(char*)_a; char* b=(char*)_b; return *a-*

2012-11-15 00:31:14 304

原创 例题5.3.1

6174问题#include#include#includeint num[2000], count;int Comp(const void* _a, const void* _b){ char* a=(char*)_a; char* b=(char*)_b; return strcmp(a,b);}int get_next(int x);

2012-11-14 23:41:05 347

原创 例题5.2.2

阶乘的准确值#include#includeconst int maxn=3000;int f[maxn];int main(){ int i,j,n; scanf("%d",&n); memset(f,0,sizeof(f)); f[0]=1; for(i=2;i<n;i++){ int c=0; for(j=0;j<maxn;j++){

2012-11-14 21:55:12 215

原创 例题5.2.1

小学生算术#includeint main(){ int a, b; while(scanf("%d%d",&a,&b)==2){ if(!a&&!b){ break; } int c=0, ans=0; for(int i=0;i<9;i++){ c=(a%10+b%10+c)>9?1:0; ans+=c; a/=1

2012-11-14 21:20:04 206

原创 例题3-4

最长回文串#include#define MAXN 5000+10char buffer[MAXN], s[MAXN];int p[MAXN];int main(){ int n, i, j, k; int max=0, m=0; int pos, x, y; cin.getline(buffer,MAXN); n=strlen(buffer);

2012-11-13 21:43:42 262

空空如也

空空如也

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

TA关注的人

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