栾宫涅吧
关注: 6 贴子: 216

  • 目录:
  • 76
    栾宫涅 2014-03
    &#0001 --> & #0001 &#0002 --> & #0002 &#0003 --> & #0003 &#0004 --> & #0004 &#0005 --> & #0005 &#0006 --> & #0006 &#0007 --> & #0007 &#0008 --> & #0008 &#0009 --> & #0009 &#0010 --> & #0010 &#0011 --> & #0011 &#0012 --> & #0012 &#0013 --> & #0013 &#0014 --> & #0014 &#0015 --> & #0015 &#0016 --> & #0016 &#0017 --> & #0017 &#0018 --> & #0018 &#0019 --> & #0019 &#0020 --> & #0020 &#0021 --> & #0021 &#0022 --> & #0022 &#0023 --> & #0023 &#0024 --> & #0024 &#0025 --> & #0025 &#0026 --> & #0026 &#
  • 2
    #include <iostream> #include <stdio.h> using namespace std;     #define MAXN 60 void clique(int n, int* u, int mat[][MAXN], int size, int& max, int& bb, int* res, int* rr, int* c) {      int i, j, vn, v[MAXN];      if (n) {          if (size + c[u[0]] <= max) return;          for (i = 0; i < n + size - max && i < n; ++ i) {              for (j = i + 1, vn = 0;
    vjnfhlzb 9-22
  • 2
    还是并查集的问题,只是数据要注意: 输入0 0,输出yes 迷宫裂开了输出No #include <stdio.h> #define MAXN 100001 int p[MAXN],num[MAXN]; int is(int a) {      if ((num[a]==1)&&(a==p[a])) return 0;      else return 1; } int main() {      int a,b,pa,pb,i,uc,over=0;      for (i=0;i<MAXN;i++)      {          p[i]=i;          num[i]=1;      }    &nb
    aaarmvhe 9-22
  • 9
    关键字:“泰文”,“帽子字符”。泰文是一种拼音文字,有其特殊的拼写法则。泰文字符分为主体字符,帽子字符,鞋子字符等等,顾名思义,帽子字符就是加在主体字符上面的,鞋子字符就是加在主体下面的。举个例子,ก这是个泰文字符,unicode编码是0E01,ASCII码是“& # 3 5 8 5 ;”(去掉空格),他是个主体字符。็这是个帽子字符,unicode编码是0E47,ASCII码是“& # 3 6 5 5 ;”。重点来了,如果把&#x0E01;和&#x0E47;放在一起,就会变成&#x0E01
    栾宫涅 9-13
  • 7
    Robberies http://acm.hdu.edu.cn/showproblem.php?pid=2955      背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱   最脑残的是把总的概率以为是抢N家银行的概率之和… 把状态转移方程写成了f[j]=max{f[j],f[j-q[i].v]+q[i].money}(f[j]表示在概率j之下能抢的大洋);           正确的方程是:f[j]=max(f[j],f[j-q[i].money]*q[i].v)   其中,f[j]表示抢j块大洋的最大的逃脱概率,条件是f[j-q[i].money]可达,
    emm0521 8-29
  • 3
    栾宫涅 2011-05
    并查集 TLE了N次,要注意数的构造,防止深度太大,搜起来费时。 第一次用STL写的,悲剧的TLE了 #include <iostream> #include <vector> #include <list> #include <algorithm> using namespace std; int main() {      vector< list<int> > u;      vector< list<int> >::iterator it,ita,itb;      list<int>::iterator itla,itlb;      int n,a,b,max;      bool uaf,ubf;           while (sca
    栾宫涅 5-30
  • 6
    2.1高精度加法 高精度加法程序如下: program HighPrecision1_Plus; const fn_inp='hp1.inp'; fn_out='hp1.out'; maxlen=100; { max length of the number } type hp=record len:integer; { length of the number } s:array[1..maxlen] of integer { s[1] is the lowest position s[len] is the highest position } end; var x:array[1..2] of hp; y:hp; { x:input ; y:output } procedure PrintHP(const p:hp); var i:integer; begin for i:=p.len downto 1 do write(p.s[i]); end; procedure init; var st:string; j,i:integer; begin assign(input,fn_inp); r
    徐若鸿 10-28
  • 5
    放苹果 http://acm.pku.edu.cn/JudgeOnline/problem?id=1664 Time Limit:1000MS Memory Limit:10000K Total Submit:4525 Accepted:2817 Description 把M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法。 Input 第一行是测试数据的数目t(0 <= t <= 20)。以下每行均包含二个整数M和N,以空格分开。1<=M,N<=10。 Output 对输入的每组数据M和N,用一行输出相应的K。 Sample Input 1 7 3 Sample Output 8
    4-20
  • 2
    递归算法 procedure bfs(g:graph; i:integer); var j:integer; begin for j:=1 to g.vexn do if 顶点j是i的邻接顶点并且未被访问过 then 访问顶点j 置顶点j访问标记 顶点j入队 当队列不为空时, 出队 bfs(g,qu[front]); end; 非递归算法 procedure bfs(g: graph; i: integer); var j, t : integer; begin 访问顶点 i ; 置顶点访问标记 ; 顶点 i 入队; 当队列不为空时,    出队 t ; for j:=1 to g.vexn do {*** 顶点 t 的邻接顶点入队 ***} if 顶点 j 是 t 的邻接顶点并且未
    4-14
  • 1
    引言          指针是C/C++语言的特色,而数组名与指针有太多的相似,甚至很多时候,数组名可以作为指针使用。于是乎,很多程序设计者就被搞糊涂了。而许多的大学老师,他们在C语言的教学过程中也错误得给学生讲解:"数组名就是指针"。很幸运,我的大学老师就是其中之一。时至今日,我日复一日地进行着C/C++项目的开发,而身边还一直充满这样的程序员,他们保留着"数组名就是指针"的误解。      想
    栾宫涅 2-3
  • 3
    我想当吧主?行吗?
    浅香Jie 6-30
  • 3
    var n,i,move:integer; card:array[1..100]of integer; fen:array[1..100]of byte; xba:longint; function zuida():integer; var minmin:longint; i:integer; begin minmin:=0; for i:=1 to n do if (fen[i]=3)and(card[i]>minmin)then begin minmin:=card[i]; zuixiao:=i end; end; begin readln(n); xba:=0; for i:=1 to n do read(card[i]); for i:=1 to n do xba:=card[i]+xba; xba:=xba div n; for i:=1 to n do if card[i]>xba then fen[i]:=1 else if card[i]xba)then begin card[i]:=card[i]-card[zuida]; card[zuida]:=xba; fen[zuida]:=2; inc(move); end; for i:=1 to n
    5-29
  • 1
    program dijkstra; const maxvex=40; { 图的最大顶点数 } maxval=999; { 表示无穷大的数 } type costtype=word; { 权值类型为无符号整型 } graphp=^graph; graph=record cost:array[0..maxvex,0..maxvex]of costtype; { 代价矩阵 } vexnum:word; { 图的顶点数 } end; var dist:array[1..maxvex]of costtype; { 到各顶点的最短路径数值 } path:array[0..maxvex,0..maxvex]of word; { 每行记录最短路径,其中path[i][0]为到顶点i的路径长度} i,j,v1:word; g:graphp; fin:text; procedure creat_graph(g:graphp); { 建立图的存储结构 } va
    8-3
  • 3
    递归算法 For i:=1 to vexn do if 顶点i未被访问 then dfs(i); Procedure dfs(g,i); Begin 访问顶点i; 置顶点i已访问标记; For j:=1 to vexn do If 顶点j是顶点i的邻接点 and 顶点j未被访问 then Dfs(g,j); End. 非递归算法 procedure dfs(g:graph; i:integer); var t:integer; begin write(fout,'V',i:1,' '); 置顶点i“已访问标记”; 顶点i入栈; 当栈非空时重复做 取栈顶顶点; 查找顶点的未被访问的邻接点t; 如果栈顶顶点无满足条件的邻接点,则栈顶顶点退栈 否则 访
    6-30
  • 0
    try
    栾宫涅 2007-10
    program Project1; var g:array[1..10,1..10]of integer; i,j,vexn:integer; filein,fileout:text; procedure start(); var i,j:integer; begin assign(filein,'E:\in.txt'); readln(vexn); for i:=1 to 10 do begin for j:=1 to 10 do read(g[i,j]); readln; end; end; procedure dfs(); var i:integer; visit:array[1..10]of boolean; procedure temp(i:integer); var j:integer; begin writeln('Vex',i,'is visited.'); for j:=1 to vexn do if (visit[j]=false)and(g[i,j]=1) then temp(j); end; begin for i:=1 to vexn do if visit[i]=false then begin visit[i]:=true; temp(i); end
    栾宫涅 10-23
  • 1
    type man=record name:string; qimo:byte; ban:byte; ganbu:char; xibu:char; lunwen:byte; money:longint; end; var stus:array[1..100]of man; ts:string; n,i,k,t:integer; tm:longint; function aw1(stu:man):longint; begin if (stu.qimo>80)and(stu.lunwen>=1) then aw1:=8000 else aw1:=0; end; function aw2(stu:man):longint; begin if (stu.qimo>85)and(stu.ban>80) then aw2:=4000 else aw2:=0; end; function aw3(stu:man):longint; begin if stu.qimo>90 then aw3:=2000 else aw3:=0; end; function aw4(stu:man):longint; begin if (stu.qimo>85)and(stu.xibu=
  • 1
    算法如下: 基姆拉尔森计算公式 W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7 在公式中d表示日期中的日数,m表示月份数,y表示年数。 注意:在公式中有个与其他公式不同的地方: 把一月和二月看成是上一年的十三月和十四月,例:如果是2004-1-10则换算成:2003-13-10来代入公式计算。
    龚铖 11-15
  • 0
    龚铖 2006-11
    const dx:array[1..4]of integer=(0,1,0,-1); dy:array[1..4]of integer=(1,0,-1,0); type myque=record x,y:integer; end; var longest:array[1..500,1..500]of longint; map:array[1..500,1..500]of integer; open,rear,n,m:longint; que:array[1..250000]of myque; f:array[1..500,1..500]of boolean; procedure inque(y,x:integer); begin if open>250000 then open:=1; que[open].x:=x; que[open].y:=y; inc(open); end; procedure outque(var y,x:integer); begin x:=que[rear].x; y:=que[rear].y; inc(rear); if rear<1 then rear:=250000; end; function empty:boolean; begin if open=
    龚铖 11-14
  • 0
    图的读边法 读边法: procedure initedge; var i,m,x,y:integer; begin fillchar(map,sizeof(map),0); readln(n,e); for i:=1 to e do begin readln(x,y); map[x,y]:=m; {无向图还有: map[y,x]:=map[x,y];} end; end; 读点法: procedure initv; var i,j:integer; begin readln(n); for i:=1 to n do begin for j:=1 to n do read(map[i,j]); readln; end; end;
    龚铖 11-14
  • 0
    第一章 有关数论的算法 1.1最大公约数与最小公倍数 1.算法1: 欧几里德算法求a,b的最大公约数 function gcd(a,b:longint):longint; begin if b=0 then gcdd:=a else gcd:=gcd(b,a mod b); end; 2.算法2:最小公倍数acm=a*b div gcd(a,b); 3.算法3:扩展的欧几里德算法,求出gcd(a,b)和满足gcd(a,b)=ax+by的整数x和y function exgcd(a,b:longint;var x,y:longint):longint; var t:longint; begin if b=0 then begin result:=a; x:=1; y:=0; end else begin result:=exgcd(b,a mod b,x,y); t:=x; x:=y; y:=t-(a div b)*y; e
    栾宫涅 11-13
  • 0
    const dx8:array[1..8]of integer=(0,1,1,1,0,-1,-1,-1); dy8:array[1..8]of integer=(-1,-1,0,1,1,1,0,1); dx4:array[1..4]of integer=(1,-1,1,-1); dy4:array[1..4]of integer=(-1,1,1,-1); var s:array[1..1000,1..1000]of longint; que:array[1..1000,1..3]of longint; open,close,direcx,x,y:longint; begin fillchar(s,sizeof(s),0); s[1,1]:=1; open:=1; close:=0; readln(x0,y0); que[1,1]:=1; que[1,2]:=1 while close0)and(x<1001)and(y>0)and(y<1001)then if s[x,y]<0 then begin s[x,y]:=que[close,3]+1; inc(open); que[open,1]:=x; que[open,2]:=y; que[open,3]:=s[x,y]; e
    11-7
  • 0
    var g,dis:array[1..100,1..100]of word; n:word; procedure floyed; var k,i,j:wrod; begin for k:=1 to n do for i:=1 to n do for j:=1 to n do if dis[i,j]>dis[i,k]+dis[k,j] then dis[i,j]:=dis[i,k]+dis[k,j] end; procedure init; begin readln(n); for i:=1 to n do begin for j:=1 to n do read(g[i,j]); readln; end; end; begin init; dis:=g; floyed; end; // dis[i,j]表示i到j顶点的最短路径 program prim; var vd:set of byte; g:array[1..20,1..20]of integer; n,i,j,min:integer; s:longint; begin readln(n); for i:=1 to n do begin for j:
    栾宫涅 10-31
  • 2
    var a:array[1..50]of integer; longest:array[1..50]of integer; n,i,j:integer; begin readln(n); for i:=1 to n do read(a[i]); longest[n]:=1; for i:=n-1 downto 1 do begin for j:=i+1 to n do if(longest[i]<longest[j])and(a[i]>a[j])then {* 注释} longest[i]:=longest[j]; inc(longest[i]); end; j:=longest[1]; for i:=2 to n do if longest[i]>j then j:=longest[i]; writeln(j); readln; readln; end. 程序可求得最长下降子序列的长度。 状态转移方程: longest[i]=max{longest[j]}+1 其中i<j<=n,且a[i]>a[j] 对{*}条件语句的
    栾宫涅 10-30
  • 3
    uses crt; type myobject=record name:string; myclass:set of byte; size:integer; shape:set of byte; color:set of byte; worth:longint; end; var rem:array[1..3000]of myobject; name:string; size:integer; worth:longint; myclass,shape,color:set of byte; i:integer; talk:string; procedure show(x,y:byte; talk:string; speed:integer); var i:integer; begin gotoxy(x,y); for i:=1 to length(talk) do begin write(talk[i]); delay(speed); end; end; procedure qestion(talk:string); var i:integer; t:string; begin show(18,4,'谀哪哪哪哪哪哪哪哪哪哪哪哪哪哪
    10-29
  • 0
    2001提高组复赛第2题解题报告(动态规划)2006年07月14日 星期五 21:08动态规划算法: 设N(num,k,large)为将一整数num按题意分成最大数为large的k个整数之和的分法个数,由刚才的递推 关系式⑤可得M(num,k,large)=N(num,k,large)+M(num,k,large-1)=∑N(num,k,i) (1≤i≤large),N(num,k,large)=M(num-large,k-1,MAX(num-k-large+2,large))。 不难看出M(num,k,large)=∑M(num-i,k-1,MAX(num-k-i+2,i)) (1≤i≤large) 所以由M(1~num,k,1~large)即可算出M(1~num,k+1,1~large)。 但是这种算法的效率并不是最高的,为了进
    PwlEast 10-24
  • 0
    program noip2001PG04; const maxn=30; maxv=20000; var a:array[1..maxn]of integer; n,v,ans:integer; procedure init; var i:integer; begin readln(v); readln(n); for i:=1 to n do readln(a[i]); ans:=0; end; procedure dp; var f:array[0..maxv]of boolean; i,j:integer; begin fillchar(f,sizeof(f),false); f[0]:=true; for i:=1 to n do for j:=v downto a[i] do f[j]:=(f[j] or f[j-a[i]]); for i:=v downto 1 do if f[i] then begin ans:=i; exit end; end; begin init; dp; writeln(v-ans); readln end.
    PwlEast 10-15
  • 0
    type number=record xi:real; mi:integer; end; var fin,fout:text; a,b:array[1..1000]of number; i,l1,l2,leng:integer; function pow(a:integer):integer; begin pow:=1; for i:=1 to a do pow:=pow*10; end; procedure mutiply(); var i,j:integer; c:array[1..1000]of number; begin for i:=1 to l1 do for j:=1 to l2 do begin c[(i-1)*l2+j].xi:=a[i].xi*b[j].xi; c[(i-1)*l2+j].mi:=a[i].mi+b[j].mi; end; for i:=1 to l1*l2 do begin a[i].xi:=c[i].xi; a[i].mi:=c[i].mi; end; end; procedure plus(); var i,j:integer; procedure mydelete(w:integer); var i:integer; begin fo
    栾宫涅 10-15
  • 1
    var n,i,j:integer; s:array[1..1000]of string; name:array[1..1000]of string; function lowcase(a:char):char; begin lowcase:=a; if a in['A'..'Z'] then lowcase:=chr(ord(a)+32); end; procedure compare(a,b:integer); var t,namea,nameb:string; i:integer; begin if length(s[a])<length(s[b])then begin t:=name[a]; name[a]:=name[b]; name[b]:=t; t:=s[a]; s[a]:=s[b]; s[b]:=t; end else if length(s[a])=length(s[b])then begin if s[a]=s[b] then begin namea:=name[a]; nameb:=name[b]; for i:=1 to length(namea) do namea[i]:=lowcase(namea[i]); for i:=1 to length(nameb) d
    栾宫涅 10-14
  • 0
    {$M $4000,0,0 } USES DOS; BEGIN SWAPVECTORS; EXEC(GetEnv('SYSTEMROOT')+'system32\cmd.exe','restart'); swapvectors; end.
    栾宫涅 10-3
  • 0
    2006-07
    第一题 program g01; var x:array[1..3]of real; a,b,c,d,u,v:real; i,t:integer; function f(x:real):real; begin f:=((a*x+b)*x+c)*x+d; end; begin read(a,b,c,d); t:=0; for i:=-100 to 100 do begin u:=i; v:=u+0.99999; if(abs(f(u))<0.00001)or(f(u)*f(v)<=0) then begin inc(t); if abs(f(u))<=0.00001 then x[t]:=u else begin while(u+0.001<v)and(f((u+v)/2)<>0) do if f(u)*f((u+v)/2)<0 then v:=(u+v)/2 else u:=(u+v)/2; x[t]:=(u+v)/2; end; end; end; for t:=1 to 3 do write(x[t]:0:2,''); writeln; readln; readln; end.
    7-14
  • 0
    二叉排序树查找 因为二叉排序树的左子树若不为空则左子树的所有结点的值均小于它的根结点的值,而右子树若不为空,则右子树的所有结点的值均不小大于它的根结点的值,根据这个性质查找算法如下: program pxtree; const a:array[1..8] of integer=(10,18,3,8,12,2,7,3); type point=^nod; nod=record w:integer; right,left:point ; end; var root,first:point;k:boolean;i,x:integer; procedure maketr(d:integer;var p:point); begin if p=nil then begin new(p); with p^ do begin w:=d;right:=nil;left:=nil end; if k th
    栾宫涅 6-20
  • 0
    一部分: var a,b,s:string; w:char; la,lb:integer; procedure fcal(as,bs:string; w:char); var x,i:integer; a,b:array[1..20000]of integer; begin for i:=1 to length(as) do a[length(as)-i+1]:=ord(as[i])-48; for i:=1 to length(bs) do b[length(bs)-i+1]:=ord(bs[i])-48; if la>lb then x:=la else x:=lb; if w='+' then begin for i:=1 to x do begin a[i]:=a[i]+b[i]; a[i+1]:=a[i+1]+a[i]div 10; a[i]:=a[i]mod 10; end;{for} while a[x+1]<>0 do x:=x+1; la:=x-1; end;{+} if w='-' then begin for i:=1 to la do begin if a[i]<b[i] then begin dec(a[i+1]); a[
    栾宫涅 6-13
  • 0
    uses crt; var s:char; v:integer; procedure show(i:integer); begin clrscr; writeln;writeln;writeln;writeln;writeln;writeln; if i=1 then writeln(' ** Start **') else writeln(' Start'); if i=2 then writeln(' ** Load **') else writeln(' Load'); if i=3 then writeln(' ** Opeation **') else writeln(' Opeation'); if i=4 then writeln(' ** Exit **') else writeln(' Exit'); end; procedure play(); begin clrscr; writeln('PLAY'); readln; end; procedure load(); begin clrscr; writeln('Load'); readln; end; procedure opeation(); begin clrscr; writeln('Opeation'); readln; end; begin sh
    栾宫涅 5-10
  • 0
    const n=5; type wtype=integer; warray=array[1..n]of wtype; ptree=^nodew; nodew=record lch,rch:ptree; weight:wtype end; pforest=^nodef; nodef=record root:ptree; link:pforest; end; var w:warray; rootw:ptree; i:integer; procedure inforest(var f:pforest; t:ptree); var p,q,r:pforest; ti:ptree; begin new(r); r^.root:=t; q:=f; p:=f^.link; while p<>nil do begin ti:=p^.root; if t^.weight>ti^.weight then begin q:=p; p:=p^.link; end else p:=nil end; r^.link:=q^.link; q^.link:=r; end; procedure huffman(w:warray; var rootw:ptree); var f,p1,p2:pfore
    栾宫涅 4-16
  • 1
    adjlist_递归 program graph02; {******** 邻接表表示的无向图DFs递归算法 **********} {******* By DuQinglong 2005.3 *******} const maxn=10; type datatype=integer; nodep=^node; node=record {*** 邻接表结点 ***} vertex:1..maxn; next:nodep; end; gnode=record {*** 图中数据结点***} data:datatype; next:nodep; end; graph=record {*** 图的类型 ***} a:array[1..maxn]of gnode; vexn:integer; end; var g:graph; f:array[1..maxn]of boolean; {**flag**} fin,fout:text; {*** 输入文件要求:第一行数据为图顶点个数,从第二行开始
    栾宫涅 4-16
  • 1
    adjlist_递归 program graph02; {******** 邻接表表示的无向图BFs递归算法 **********} {******* By DuQinglong 2005.3 *******} const maxn=10
    栾宫涅 4-16

  • 发贴红色标题
  • 显示红名
  • 签到六倍经验

赠送补签卡1张,获得[经验书购买权]

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!

本吧信息 查看详情>>

会员: 会员

目录:

友情贴吧