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,加我一起讨论问题,一起进步^-^
时间: 2024-10-14 19:17:06