讨论 / 谁能给我源程序
hhy8926351 2008-08-30 03:50:00
点我顶贴 收藏 删除
我需要这题的源程序

谁能给我

顺便问下RQNOJ可以使用文件输入么

NOIP的时候怎样使用文件输入

#1 sxpeter@2008-06-30 21:20:00
回复 删除
var

n:integer;

k:char;

win:array[1..30000]of boolean;

procedure putin;

var

t,i:longint;

begin

while k<>E do begin

read(k);

if k=Wthen begin

inc(n);win[n]:=true;t:=t+1;

{No.6}

if t>20000then begin

for i:=1 to 50000 div 11 do writeln(11:0);

writeln(50000 mod 11,:0);

writeln;

for i:=1 to 50000 div 21 do writeln(21:0);

writeln(50000 mod 21,:0);halt;end;

{/No.6} end;

if k=Lthen begin

inc(n);win[n]:=false;t:=-maxlongint;end;

if k=Ethen exit;

end;

end;

procedure jsing(s:integer);

var t,a,b:integer;

begin

t:=0;

a:=0;

b:=0;

if n=0 then begin writeln(0:0);exit;end;

while t<n do begin

inc(t);

if win[t]then inc(a) else inc(b);

if((a>=s)or(b>=s))and(abs(a-b)>=2)then begin

writeln(a,:,b);

a:=0;b:=0;end;

end;

writeln(a,:,b);

end;

begin

putin;

jsing(11);

writeln;

jsing(21);

end.

#2 000wang@2008-07-01 02:32:00
回复 删除
type

data=record

k3,k4:integer;

end;

Var s,f,g:string;

k1,k2,k3,k4,j1,j2,j,l,i:longint;

e:boolean;

a:array[0..100000] of data;

Begin

k1:=0; k2:=0; k3:=0;k4:=0;j1:=1;j:=0; j2:=1;

e:=False;

While Not(eof(Input)) and Not(e) do

Begin

readln(s);

l:=length(s);

For i:=1 to l do

Begin

If ((k1>=11) or (k2>=11)) and (abs(k1-k2)>=2) Then

Begin writeln(k1,:,k2);

k1:=0; k2:=0

End;

If s[i]=W Then inc(k1);

If s[i]=L Then inc(k2);

If s[i]=E Then Begin e:=True; break End;

End;

For i:=1 to l do

Begin

If ((k3>=21) or (k4>=21)) and (abs(k3-k4)>=2) Then

Begin

j:=j+1;

a[j].k3:=k3;a[j].k4:=k4;

k3:=0; k4:=0

End;

If s[i]=W Then k3:=k3+1;

If s[i]=L Then k4:=k4+1;

If s[i]=E Then Begin e:=True; break End;

End;

End;

writeln(k1,:,k2);

writeln;

for i:=1 to j do

writeln(a[i].k3,:,a[i].k4);

write(k3,:,k4);

End.

#3 000wang@2008-07-01 02:37:00
回复 删除
一般是begin后面加assign(input,文件名);reset(input);

assign(output,文件名);rewrite(output);

最后加上close(input);close(output);

像这样

var ....

begin

assign(input,文件名);reset(input);

assign(output,文件名);rewrite(output);

.....(main)

close(input);close(output);

end.

can you understand?

#4 hhy8926351@2008-07-01 22:37:00
回复 删除
3楼的 不能用文件不是?
#5 000wang@2008-07-02 02:23:00
回复 删除
RQNOJ中题不用文件
#6 hhy8926351@2008-07-02 20:56:00
回复 删除
那如何AC
#7 自由狂想论@2008-07-02 22:30:00
回复 删除
var

a:array[0..1000000]of boolean;

i,u,w,l:longint;

ch:char;

begin

u:=0;

repeat

read(ch);

if ch=W then begin

inc(u);

a[u]:=true;

end

else if ch=L then begin

inc(u);

a[u]:=false;

end;

until ch=E;

for i:=1 to u do

begin

if a[i] 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;

writeln(w,:,l); w:=0; l:=0; writeln;

for i:=1 to u do

begin

if a[i] 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;

writeln(w,:,l);

end.

#8 vinence@2008-07-03 01:33:00
回复 删除
const maxn=10000;

var

out:array[1..maxn,0..2]of longint;

top,s1,s2,o1,o2:longint;

procedure init;

var ch:char;

begin

repeat

read(ch);

if ch=Wthen begin

inc(s1);inc(o1);

end;

if ch=L then begin

inc(s2);inc(o2);

end;

if ((s1>=11) or (s2>=11)) and (abs(s1-s2)>1) or (ch=E) then begin

writeln(s1,:,s2);

s1:=0;s2:=0;end;

if ((o1>=21) or (o2>=21)) and (abs(o1-o2)>1) or (ch=E) then begin

inc(top);

out[top,1]:=o1;

out[top,2]:=o2;

o1:=0;o2:=0;

end;

until ch=E;

end;

procedure print;

var i:longint;

begin

writeln;

for i:=1 to top do writeln(out[i,1],:,out[i,2]);

end;

begin

init;

print;

end.

#9 heyong@2008-07-04 04:20:00
回复 删除
var

i,k,s1,s2:longint;

a:array[1..10000000] of char;

begin

i:=0;

repeat

inc(i);

read(a[i]);

if i mod 20 =0 then readln;

until a[i]=E;

k:=i-1;

s1:=0;

s2:=0;

for i:=1 to k do

begin

if a[i]=W then inc(s1);

if a[i]=L then inc(s2);

if ((s1>=11)or(s2>=11))and(abs(s1-s2)>=2)

then begin

writeln(s1,:,s2);

s1:=0;

s2:=0;

end;

end;

writeln(s1,:,s2);

writeln;

s1:=0;

s2:=0;

for i:=1 to k do

begin

if a[i]=W then inc(s1);

if a[i]=L then inc(s2);

if ((s1>=21)or(s2>=21))and(abs(s1-s2)>=2)

then begin

writeln(s1,:,s2);

s1:=0;

s2:=0;

end;

end;

writeln(s1,:,s2);

end.

#10 少年包工头@2008-07-13 00:34:00
回复 删除
program pingpong;

var

s:packed array [1..100000] of char;

c:char;

i,j,l,t1,t2:longint;

begin

repeat

i:=i+1;

read(c);

if c<>E then s[i]:=c;

until c=E;

for j:=1 to i do

begin

if s[j]=W then t1:=t1+1;

if s[j]=L then t2:=t2+1;

if (t1>=11) or (t2>=11) then if abs(t1-t2)>1 then begin

writeln(t1,:,t2);

t1:=0;

t2:=0;

end;

end;

writeln(t1,:,t2);

writeln;

t1:=0;

t2:=0;

for j:=1 to i do

begin

if s[j]=W then t1:=t1+1;

if s[j]=L then t2:=t2+1;

if (t1>=21) or (t2>=21) then if abs(t1-t2)>1 then begin

writeln(t1,:,t2);

t1:=0;

t2:=0;

end;

end;

writeln(t1,:,t2);

end.

查看更多回复
提交回复