| 
                
                    | 
    
        
            
    二叉树(创建、先序、中序、后序遍历)
    
            
摘要:二叉树的创建与遍历:#include <iostream>#include <stdio.h>#include <string.h>using namespace std;char *str="";//二叉树结点的定义typedef struct BTNode{char data;struct BTNode *lc;struct BTNode *rc;}BTNode,*BiTree;void Creat(BiTree &T){ char ch[2]; scanf("%s",&ch[0]);//cin.g
        阅读全文 
            
    Codeforces Round #100 总结 (pi=acos(-1.0)!!!cos(d),d为弧度!!!)
    
            
摘要:就做出了一道题,当初一道都做不出的我是不是脑残?偶然发现,第100场时,大家都那么水,看来所谓的蓝紫都是上学期练出来的。#include <iostream>#include <stdio.h>#include <math.h>#define pi acos(-1.0)using namespace std;int main(){ double n,R,r; while(cin >> n >> R >>r){ if(n==1 || n==2){ if(R>=r*n) cout <<"YES&qu
        阅读全文 
            
    hdu-4355(三分求极值)
    
            
摘要:打表发现题中函数满足凸函数性质,于是三分。View Code #include <iostream>#include <math.h>#include <stdio.h>#define eps 1e-9using namespace std;int n;struct P{ double x,w;}p[50005];double Calc(double i){ double S=0.0; for(int j=0;j<n;j++){ S+=fabs((i-p[j].x)*(i-p[j].x)*(i-p[j].x))*p[j].w; } return S;.
        阅读全文 
            
    2012 Multi-University Training Contest 6
    
            
摘要:我就做了个1006啊!!!签到题啊!!!三分模板题啊!!!因为用cin输入而不用scanf一顿TLE啊!!!现学现卖,三分求凸函数极值。打表发现该函数符合凸函数性质,于是三分。View Code #include <iostream>#include <math.h>#include <stdio.h>#define eps 1e-9using namespace std;int n;struct P{ double x,w;}p[50005];double Calc(double i){ double S=0.0; for(int j=0;j<n;j
        阅读全文 
            
    Codeforces Round #116 (Div. 2, ACM-ICPC Rules)
    
            
摘要:C题:思路清晰题,有点贪心的感觉。View Code #include <iostream>#include <string.h>using namespace std;int main(){ char s[100005]; while(cin >> s){ int len=strlen(s); int cous=0,coul=0; int minc=100005; for(int i=0;i<len;i++){ if(s[i]>='a' && s[i]<='z') cous++; ...
        阅读全文 
            
    Codeforces Round #113 (Div. 2) (pow的时间复杂度是O(n))
    
            
摘要:A题:手速题,排序C题:思维清晰题,分类讨论E题:思维清晰题,找规律,(pow的时间复杂度是O(n)!!!)#include <iostream>#include <math.h>#include <stdio.h>using namespace std;long long a[10000005];int main(){ a[1]=0; a[2]=3; a[3]=6; a[4]=21; /*for(int i=5;i<=1000;i++){ //a[i]=((int)pow(3.0,double(i-1))-a[i-1])%1000000007; ..
        阅读全文 
            
    Codeforces Round #102 (Div. 2)总结(如何处理A*B*C==n!!!)
    
            
摘要:A题:手速题B题:分类讨论题C题:暴力+优化的数学题#include <iostream>#include <math.h>using namespace std;int main(){ long long n; while(cin >> n){ unsigned long long maxc=0,minc=1844674407370955161; for(long long i=1;i*i<=n;i++){ if(n%i==0){ long long bc=n/i; fo...
        阅读全文 
            
    Codeforces Round #112 (Div. 2) & #125 (Div. 2)总结(不要用pow&log!!!)
    
            
摘要:1.遇到需要用大数处理的问题,一定要先去思考能避开大数的程序,不要上来就用c++大数模板或java大数函数,前者敲起来繁琐,后者效率太低。#include <stdio.h>#include <iostream>using namespace std;int main(){ long long k,b,n,t,z; while(cin >> k >> b >> n >>t){ long long x=1; int cou=0; while(x<=t && cou<=n){ x=k*x+b; co
        阅读全文 
            
    Codeforces Round #118 (Div. 2) B题(Codeforces上不支持qsort,只支持sort!!!)
    
            
摘要:一道裸的排序题,本应该瞬秒的,结果一直WA在第十组数据上,我很确信我的程序是对的,但就是WA。后来看了别人的代码,原来错在了qsort与sort的使用上!大家看一下我WA了8次的代码:#include <iostream>#include <stdio.h>#include <stdlib.h>using namespace std;struct P{ int num; double h;}p[10005];int cmp( const void *a , const void *b ){ struct P *c = (struct P *)a; struc
        阅读全文 
            
    hdu-4308(bfs)
    
            
摘要:多校第9题:巧妙的广搜,遇到第一个P的时候,将所有的其他P都压入队列,再搜下去就会接着P开始往下搜,搜到C结束。附代码:View Code #include <iostream>#include <string.h>#include <stdio.h>using namespace std;#define V 5010char map[V][V];bool vis[V][V];int dir[4][2]={{1,0},{0,1},{0,-1},{-1,0}};struct Node{ int x,y; long long step;}q[V];int r,c
        阅读全文 
            
    对拍程序C语言实现
    
            
摘要://对于自己写的程序,到网上搜一个正确的程序,对同一组测试数据,进行运行,最后比较#include<stdio.h>#include<string.h>char n[520000][10],m[520000][10];int main(){ int i=0,j=0; freopen("AC.txt","r",stdin); //标准程序运行结果文件 while(~scanf("%s",n[i++])); freopen("WA.txt","r",stdin); //你的程
        阅读全文 
            
    国家集训队论文分类
    
            
摘要:假期要将论文扫一遍。 组合数学计数与统计2001 - 符文杰:《Pólya原理及其应用》2003 - 许智磊:《浅谈补集转化思想在统计问题中的应用》2007 - 周冬:《生成树的计数及其应用》2008 - 陈瑜希《Pólya计数法的应用》数位问题2009 - 高逸涵《数位计数问题解法研究》2009 - 刘聪《浅谈数位类统计问题》动态统计2004 - 薛矛:《解决动态统计问题的两把利刃》2007 - 余江伟:《如何解决动态统计问题》博弈2002 - 张一飞:《由感性认识到理性认识——透析一类搏弈游戏的解答过程》2007 - 王晓珂:《解析一类组合游戏》2009 - 曹钦翔《从
        阅读全文 
            
    bfs/dfs(邻接矩阵)
    
            
摘要:#include <iostream>#include <string.h>#include <stdio.h>using namespace std;#define V 3000#define E 10000int map[V][V];int vis[V];int n,m,st,end;int queue[V];void dfs(int u){ vis[u]=1; for(int i=1;i<=n;i++) { if(vis[i]==0 && map[u][i]==1) { dfs(i); //vis[...
        阅读全文 
            
    bfs/dfs(邻接表)
    
            
摘要:#include <iostream>#include <stdio.h>#include <string.h>#define E 500500#define V 10050using namespace std;struct edge{ int s,t,next;}e[E];int head[V];int queue[V];int cnt,n,m,st,end;int vis[V];void addedge(int u,int v){ e[cnt].s=u; e[cnt].t=v; e[cnt].next=head[u]; head[u]=cnt++;}v
        阅读全文 
    
 |  |  |