- 表达式求值
- 2016-11-19 22:09:03 @
var
s: Ansistring;
function change(t,w: Longint): Longint;
var
i,b,total: Longint;
begin
b:=1;
total:=0;
if (w-t)>3 then t:=w-3;
for i:=w downto t do
begin
total:=total+b*(ord(s[i])-ord('0'));
b:=b*10;
end;
exit(total);
end;
function search(t,w: Longint): Longint;
var
i,j,total: Longint;
begin
for i:=t to w do if s[i]='+' then exit((search(t,i-1)+search(i+1,w)) mod 10000);
for i:=t to w do if s[i]='*' then exit((search(t,i-1)*search(i+1,w)) mod 10000);
exit(change(t,w));
end;
begin
readln(s);
write(search(1,Length(s)));
end.
0 条评论
目前还没有评论...
信息
- ID
- 1849
- 难度
- 7
- 分类
- (无)
- 标签
- 递交数
- 3592
- 已通过
- 768
- 通过率
- 21%
- 被复制
- 10
- 上传者