前言:不要被标题所迷惑!也不要被我的话所迷惑!
P1023 税收与补贴问题 请点击:税收与补贴问题题解
P1031 均分纸牌 总:这个……真的是模拟了。
var n,i,s,ans:longint; a:array [1..10001] of longint;begin readln(n); s:=0; for i:=1 to n do begin read(a[i]); s:=s+a[i]; end; s:=s div n; ans:=0; if a[1]<>s then begin if a[1]<s then begin a[2]:=a[2]-(s-a[1]); a[1]:=s; end else begin a[2]:=a[2]+(a[1]-s); a[1]:=s; end; inc(ans); end; if a[n]<>s then begin if a[n]<s then begin a[n-1]:=a[n-1]-(s-a[n]); a[n]:=s; end else begin a[n-1]:=a[n-1]+(a[n]-s); a[n]:=s; end; inc(ans); end; for i:=2 to n-1 do begin if a[i]<>s then begin if a[i]<s then begin a[i+1]:=a[i+1]-(s-a[i]); a[i]:=s; end else begin a[i+1]:=a[i+1]+(a[i]-s); a[i]:=s; end; inc(ans); end; end; write(ans);end.P1042 乒乓球 总:怀念小学,那时用字符串写,坑了我啊(忘了怎么坑的)。 这题……又是模拟。
var a:array [1..1000001] of char; i,j,k,n,w,l,w1,l1:longint;begin repeat i:=i+1; read(a[i]); until a[i]='E'; i:=0; repeat i:=i+1; if (a[i]='W') or (a[i]='L') then begin if a[i]='W' then inc(w) else inc(l); if ((w>=11) or (l>=11)) and (abs(w-l)>=2) then begin writeln(w,':',l); w:=0; l:=0; end; end; until a[i]='E'; writeln(w,':',l); writeln; i:=0; w:=0; l:=0; repeat i:=i+1; if (a[i]='W') or (a[i]='L') then begin if a[i]='W' then inc(w) else inc(l); if ((w>=21) or (l>=21)) and (abs(w-l)>=2) then begin writeln(w,':',l); w:=0; l:=0; end; end; until a[i]='E'; write(w,':',l);end.P1086 花生采摘 总:贪心策略,先拿大的。
var m,n,k,nm,ans:longint; x,y,a:array [0..401] of longint;PRocedure init;var i,j,o:longint;begin readln(m,n,k); for i:=1 to m do for j:=1 to n do begin read(o); if o>0 then begin inc(nm); x[nm]:=i; y[nm]:=j; a[nm]:=o; end; end;end;procedure pd;var i,j,t:longint;begin for i:=1 to nm do for j:=1 to nm do if a[i]>a[j] then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; t:=x[i]; x[i]:=x[j]; x[j]:=t; t:=y[i]; y[i]:=y[j]; y[j]:=t; end;end;procedure main;var i:longint;begin ans:=0; y[0]:=y[1]; if k<>0 then for i:=0 to nm do if k>=abs(x[i]-x[i+1])+abs(y[i]-y[i+1])+1+x[i+1] then begin k:=k-abs(x[i]-x[i+1])-abs(y[i]-y[i+1])-1; ans:=ans+a[i+1] end else break; write(ans);end;begin init; pd; main;end.P1098 字符串的展开 总:就是判断输出啊。
var s,s1,s2:ansistring; i,j,n,m,x,y,z:longint;procedure hjy(o:longint);var i,j:longint;begin s1:=''; s2:=''; if ord(s[o-1])>=ord(s[o+1]) then exit; if ord(s[o-1])+1=ord(s[o+1]) then begin delete(s,o,1); exit; end; for i:=ord(s[o-1])+1 to ord(s[o+1])-1 do for j:=1 to y do s1:=s1+chr(i); if x=2 then for i:=1 to length(s1) do if (s1[i]>='a') and (s1[i]<='z') then s1[i]:=chr(ord(s1[i])-32); if x=3 then for i:=1 to length(s1) do s1[i]:='*'; if z=2 then begin for i:=1 to length(s1) do s2:=s2+s1[length(s1)-i+1]; s1:=s2; end; delete(s,o,1); insert(s1,s,o);end;begin readln(x,y,z); readln(s); n:=length(s); i:=2; s:=s+'+'; while s[i]<>'+' do begin if (s[i-1]<>'-') and (s[i+1]<>'-') then if (s[i]='-') and (((ord(s[i-1])>=97) and (ord(s[i+1])>=97)) or ((ord(s[i-1])<=57) and (ord(s[i+1])<=57))) then hjy(i); inc(i); end; delete(s,length(s),1); writeln(s);end.新闻热点
疑难解答