Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为什么我算给出的数据一闪而过,交上去却TLE了?

Posted by zhengzeyu at 2006-10-30 23:23:38 on Problem 1145
我的程序如下:
var tmp,next:char;
    flag:boolean;
    ask:longint;
function readnext:char;
  begin
    readnext:=next;
    while seekeoln(input) do
      if seekeof(input) then exit;
    read(next);
  end;
function main(now:longint):boolean;
  var ch1,ch2:char;
      num:longint;
      opp:boolean;
  begin
    ch1:=readnext;
    ch2:=readnext;
    main:=false;
    if ch2=')' then begin
      main:=true;
      exit;
    end;
    num:=0;
    opp:=false;
    if ch2='-' then opp:=true else num:=ord(ch2)-48;
    while next<>'(' do begin
      ch2:=readnext;
      num:=num*10+ord(ch2)-48;
    end;
    if opp then num:=-num;
    if main(now+num) then
      if main(now+num) then begin
        if now+num=ask then flag:=true
      end else
    else
      if main(now+num) then flag:=flag;
    tmp:=readnext;
  end;
begin
//  assign(input,'input.txt'); reset(input);
//  assign(output,'output.txt'); rewrite(output);
  tmp:=readnext;
  while not seekeof(input) do begin
    ask:=0;
    while next<>'(' do
      ask:=ask*10+ord(readnext)-48;
    flag:=false;
    if main(0) then flag:=flag;
    if flag then writeln('yes') else writeln('no');
  end;
//  close(input); close(output);
end.


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator