| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
帮我看看code.好像计算有错。。。(pascal)In Reply To:不知道为什么WA谁能告诉我n=8~15分别等于什么?8 =〉10 ,9 =〉11 15 =〉 1400 ??? Posted by:My_loves at 2005-09-29 23:06:33 program p1950;
const a:array[11..15]of integer=(88,162,200,441,1400);
var n:byte;
total:integer;
procedure cal(s:string);
var i:byte;
num,j,k,code:integer;
l:char;
begin
s:=s+'+';
num:=0;
j:=0;
l:='+';
for i:=1 to length(s) do
begin
if s[i]='.' then continue;
if (s[i]='+') or (s[i]='-')then
begin
if l='+' then num:=num+j;
if l='-' then num:=num-j;
l:=s[i];
j:=0;
continue;
end;
val(s[i],k,code);
j:=j*10+k;
end;
s:=copy(s,1,length(s)-1);
if num=0 then begin
inc(total);
if total<=20 then writeln(s);
if total=20 then begin writeln(a[n]);halt end;
end;
end;
procedure main(x:byte;s:string);
var i:string[3];
begin
if x=n then
begin
cal(s);
exit;
end;
str(x+1,i);
main(x+1,s+'+'+i);
main(x+1,s+'-'+i);
main(x+1,s+'.'+i);
end;
begin
readln(n);
main(1,'1');
writeln(total);
end.
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator