Category: 其他

  • 不是每个男生都叫SXKDZ

    【点名】不是每个男生都叫SXKDZ
    00、以下25条都是真心的。
    01、SXKDZ很瘦。
    02、SXKDZ睡觉姿势多变,起来以后的发型总是很令人吃惊,经常被被人说是烫过头发。
    03、SXKDZ很怕冷,但不怕热。因此冬天穿得很多。
    04、SXKDZ很喜欢摇滚,又听又唱,觉得自己在变声期没有办法吼高音很遗憾。
    05、SXKDZ唯一追的明星是Beyond,几乎能唱Beyond组合每一首歌。
    06、SXKDZ其实不怎么喜欢牛奶,但是从小就喝。
    07、SXKDZ希望很平淡地对待每个人但是总是因为一些事情改变对某些人的看法,然后过几天又改回来。
    08、SXKDZ一点都不喜欢体育运动。
    09、SXKDZ唯一不吃腊肉(及腊制品),其他的东西不挑。
    10、SXKDZ喜欢文静的女生。
    11、SXKDZ会把被拜托的事情一直放在心上,而且想尽早完成。
    12、SXKDZ不喜欢呆在很多人闹的地方,但不会介意呆在这些地方,SXKDZ不会融入这个吵吵的环境而是想想别的。
    13、SXKDZ想变得成熟,不知道是不是因为早恋过。
    14、SXKDZ很少发呆。
    15、SXKDZ会跟谈得来的朋友玩得好,但是实在没有共同语言也没办法。
    16、SXKDZ很喜欢了解别人的心理。
    17、SXKDZ讨厌善意的谎言。
    18、SXKDZ很怕蟑螂、蜈蚣等小的昆虫。
    19、SXKDZ怕黑,但是也不喜欢阳光。
    20、SXKDZ不用耳机,总是用外放,而且喜欢边走边听边摇头,会跟着一起唱,声音能放多大就放多大。
    21、SXKDZ会做一名程序员,但是苦恼编程的时间太少,而且自己技术很差。
    22、SXKDZ对文学没有什么感觉,只是偏爱会抒情的作家和会幽默的作家(漫画等除外)。
    23、SXKDZ的嘴很毒,经常在不经意之间伤害最近的朋友……
    24、SXKDZ不太相信爱情了。
    25、SXKDZ会跟着音乐一起唱,不会想别的。

  • 【转载】NOIp2011普及组题解

    NOIP2011普及组解题报告
    ——ahbbzeq 2011.11.25 转载请注明来源
    一、数字反转
    没得满分只能说明一个问题,你的程序写的太少了。
    [delphi]
    program reverse;
    var
    s:string;
    i,sta:longint;
    begin
    assign(input,’reverse.in’);reset(input);
    assign(output,’reverse.out’);rewrite(output);

    readln(i);
    str(i,s);
    sta:=1;
    if s[1]=’-‘ then
    begin
    write(‘-‘);
    sta:=2;
    end;
    i:=length(s);
    while (s[i]=’0’) and (i>sta) do
    dec(i);
    while (i>=sta) do
    begin
    write(s[i]);
    dec(i);
    end;

    close(input);close(output);
    end.
    [/delphi]

    二、统计单词个数
    考你的基本功,和对程序的理解,尤其是细节上的优化。直接在文章中选出单词,与给定单词长度一致时才比较,函数传参数时也不要传字符串(会很慢的,具体慢多少没试)。
    [delphi]
    program stat;
    var
    s,p:ansistring;
    i,j,first,num,len,c,k:longint;

    function cmp(x:longint):boolean;
    var
    i:longint;
    begin
    for i:= 1 to c do
    if s[i]<> p[x+i-1] then exit(false);
    exit(true);
    end;
    begin
    assign(input,’stat.in’);reset(input);
    assign(output,’stat.out’);rewrite(output);

    readln(s);readln(p);
    s:=upcase(s);p:=upcase(p);
    c:=length(s); len:=length(p);
    i:=1; num:=0; first:=-1;
    while (s[i]=’ ‘)and (i<=len) do inc(i); while (i<=len) do begin j:=i+1; while (p[j]<>‘ ‘) and (j<=len) do inc(j); if (j-i = c) and cmp(i) then begin if first=-1 then first:=i; inc(num); end; i:=j; while (p[i]=' ') and (i<=len) do inc(i); end; if first=-1 then writeln(-1) else writeln(num,' ',first-1); close(input);close(output); end. [/delphi] 三、瑞士轮 实践证明,如果单纯的排序r次,必然结果是超时。事实上只需一次真正意义上的排序以后,在以后的比赛中,按原顺序分成两组,获胜组和失败组,这两组依然是有序的,再把这两组归并成一组,就可以了。总时间复杂度O(N*R)。 为了方便归并,下面的数组采用了滚动数组。 [delphi] program swiss_merger; var n,r,q,i,j,k,c,pwin,plose:longint; s,w,t:array[1..200050] of longint; id:array[0..1,1..200050] of longint; procedure qsort(n,m:longint); var i,j,k,t:longint; begin i:=n;j:=m; k:= id[0,(n+m)div 2]; repeat while (s[id[0,i]] > s[k]) or (s[id[0,i]]=s[k]) and (id[0,i]k) do dec(j);
    if i<=j then begin t:=id[0,i]; id[0,i]:=id[0,j];id[0,j]:=t; inc(i); dec(j); end; until i>j;
    if n s[ id[1-c,plose] ]) or (s[id[1-c,pwin]] = s[ id[1-c,plose] ] ) and ( id[1-c,pwin]< id[1-c,plose] ) ) then begin id[c,j]:=id[1-c,pwin]; inc(pwin,2); end else begin id[c,j]:=id[1-c,plose]; inc(plose,2); end; end; writeln(id[c,q]); close(input);close(output); end. [/delphi] 四、表达式的值 算法类似于表达式计算,一个符号栈,两个数据栈。记f(s,0)表示表达式s为0的方案数,f(s,1)表示表达式s为1的方案数。f(a+b,0) = f(a,0)*f(b,0) ,f(a+b,1) = f(a,0)*f(b,0)+f(a,0)*f(b,1)+f(a,1)*f(b,0) , f(a*b,0)=f(a,0)*f(b,0) + f(a,1)*f(b,0) + f(a,0)*f(b,1) , f(a*b,1) = f(a,1) * f(b,1) [delphi] program exp; const maxn= 100010; op:array[1..4] of char = ('(','+','*',')'); // ( + * ) flag:array[1..4,1..4] of char = ( { ( } ('<','<','<','='), { + } ('<','>‘,’<','>‘),
    { * } (‘<','>‘,’>’,’>’),
    { ) } (‘>’,’>’,’>’,’>’));
    var
    stack_op:array[1..maxn] of char;
    stack_data0,stack_data1:array[1..maxn] of longint;
    n,top_op,top_data,i,len:longint;
    a0,a1,b0,b1,t0,t1:longint;
    s:ansistring;
    ch,now:char;
    procedure push_op(ch:char);
    begin
    inc(top_op);
    stack_op[top_op]:=ch;
    end;
    function pop_op:char;
    begin
    pop_op:= stack_op[top_op];
    dec(top_op);
    end;
    function gettop:char;
    begin
    gettop:=stack_op[top_op];
    end;
    procedure push_data(a0,a1:longint);
    begin
    inc(top_data);
    stack_data0[top_data]:=a0;
    stack_data1[top_data]:=a1;
    end;
    procedure pop_data(var a0,a1:longint);
    begin
    a0:=stack_data0[top_data];
    a1:=stack_data1[top_data];
    dec(top_data);
    end;
    function find(ch:char):integer;
    var
    i:longint;
    begin
    for i:= 1 to 4 do
    if op[i]=ch then exit(i);
    end;
    begin
    assign(input,’exp.in’);reset(input);
    assign(output,’exp.out’);rewrite(output);
    top_op:=0; top_data:=0;
    push_op(‘(‘); push_data(1,1);
    readln(n);
    readln(s); s:=s+’)’;
    len:=length(s);
    i:=1;
    while i<=len do begin if i=22 then readln; case flag[find(gettop),find(s[i])] of // begin '<': begin push_op(s[i]); if (s[i]<>‘(‘) then push_data(1,1); inc(i); end;
    ‘=’: begin now:=pop_op; inc(i); end;
    ‘>’: begin
    pop_data(a0,a1); pop_data(b0,b1);
    now:=pop_op;
    if now=’+’ then
    begin
    t0:= (a0*b0) mod 10007;
    t1:= ( (a0*b1) mod 10007 +(a1*b1) mod 10007 + (a1*b0) mod 10007) mod 10007;
    push_data(t0,t1);
    end
    else
    begin
    t0:= ( (a0*b1) mod 10007 + (a1*b0) mod 10007 + (a0 * b0) mod 10007 ) mod 10007;
    t1:= (a1*b1) mod 10007;
    push_data(t0,t1);
    end;
    end;
    end;
    end;
    writeln(stack_data0[top_data]);
    close(input); close(output);
    end.
    [/delphi]

  • 大家好!!我来了!!

    欢迎来到SXKDZ的实验室哦~
    我可能会有点懒,有时候很久才写日志。不过我还是会关注博客的!
    谢谢FC提供的空间!