zoukankan      html  css  js  c++  java
  • 9-25 解题报告

    1.catfish

    var
            n,k,ans,tot:int64;
            i,j:longint;
            a:array[0..100] of int64;
            f:array[0..40] of int64;
    
            begin
                    assign(input,'catfish.in');
                    reset(input);
                    assign(output,'catfish.out');
                    rewrite(output);
                    readln(n);        f[1]:=1;
                    for i:=2 to 31 do f[i]:=3*f[i-1];
                    for j:=1 to n do
                    begin
                            read(k); tot:=0;
                            ans:=0;
                            while k<>0 do
                            begin
                                    inc(tot);
                                    a[tot]:=k mod 2;
                                    k:=k div 2;
                            end;
                            for i:=tot downto 1 do
                            if a[i]=1 then inc(ans,f[i]);
                            writeln(ans);
                    end;
                    close(input);
                    close(output);
            end.

    2.meal

    var
            map,f,up,left,right,leftup,rightup,f1,f2:array[0..1,0..2505] of longint;
            temp,i,j,ii,k,l,m,n,max,t:longint;
    
    
            function min(a,b,c:longint):longint;
            begin
                    if a<b then min:=a
                    else min:=b;
                    if c<min then min:=c;
            end;
    
            begin
                    assign(input,'meal.in');
                    reset(input);
                    assign(output,'meal.out');
                    rewrite(output);
                    while not eof do
                    begin
                            fillchar(up,sizeof(up),0);
                            fillchar(left,sizeof(up),0);
                            fillchar(right,sizeof(up),0);
                            fillchar(f1,sizeof(up),0);
                            fillchar(f2,sizeof(up),0);
                            fillchar(map,sizeof(up),10);
    
                            readln(n,m);
                            max:=0;
                            t:=1;
                            for i:=1 to m do
                            begin
                                    read(map[t][i]);
                                    if map[t][i]=1 then
                                    begin
                                            rightup[t][i]:=1;
                                            leftup[t][i]:=1;
                                            f1[t][i]:=1;
                                            f2[t][i]:=1;
                                            max:=1;
                                            continue;
                                    end;
                                    up[t][i]:=1;
                            end;
                            readln;
                            for ii:=2 to n do
                            begin
                                    t:=t xor 1;
                                    for i:=1 to m do
                                    begin
                                            left[t][i]:=0;
                                            right[t][i]:=0;
                                            up[t][i]:=0;
                                            leftup[t][i]:=0;
                                            rightup[t][i]:=0;
                                            f1[t][i]:=0;
                                            f2[t][i]:=0;
                                    end;
    
                            for i:=1 to m do
                            begin
                                    read(map[t][i]);
                                    if map[t][i]=1 then
                                    begin
                                            f1[t][i]:=1;
                                            f2[t][i]:=1;
                                            continue;
                                    end;
                                    left[t][i]:=1;
                                    right[t][i]:=1;
                                    up[t][i]:=1;
                            end;
                            readln;
    
                            for i:=1 to m do if map[t][i]=0 then
                            begin
                                    if map[t][i-1]=0 then left[t][i]:=left[t][i-1]+1;
                                    if map[t xor 1,i]=0 then up[t][i]:=up[t xor 1,i]+1;
                            end;
    
                            for i:=m downto 1 do if map[t][i]=0 then
                            begin
                                    if map[t][i+1]=0 then right[t][i]:=right[t][i+1]+1;
                            end;
    
                            for i:=1 to m do if (map[t][i]=1) and (map[t xor 1][i-1]=1) then
                            begin
                                    f1[t][i]:=min(left[t][i-1],up[t xor 1][i],f1[t xor 1][i-1])+1;
                                    if max<f1[t][i] then max:=f1[t][i];
                            end;
    
                            for i:=1 to m do if (map[t][i]=1) and (map[t xor 1][i+1]=1) then
                            begin
                                    f2[t][i]:=min(right[t][i+1],up[t xor 1][i],f2[t xor 1,i+1])+1;
                                    if max<f2[t][i] then max:=f2[t][i];
                            end;
                            end;
                            writeln(max);
                    end;
                    close(input);
                    close(output);
            end.

    第三题指针,真心不会,熟悉pascal的大神求包养QvO

     喜欢就收藏一下,vic私人qq:1064864324,加我一起讨论问题,一起进步^-^

  • 相关阅读:
    [Redis]主从同步可能遇到的坑
    Redis_如何保证原子操作
    .Net Core 5.0 Json序列化和反序列化 | System.Text.Json 的json序列化和反序列化
    JavaScript Error对象整理_JavaScript 异常处理整理
    Canvas 事件绑定|Canvas事件处理
    Css3 常用布局方式 一行两列&高度自适应&垂直方向居中
    Css3 实现锯齿效果整理
    Css3 currentColor 变量使用
    Css3 实现任意角扇形|Css3实现六角扇形
    实现 Application_Start 和 Application_End
  • 原文地址:https://www.cnblogs.com/victorslave/p/4839517.html
Copyright © 2011-2022 走看看