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

Re:输入1(或-1)是多少?

Posted by realmajia at 2005-01-30 20:33:45 on Problem 1730
In Reply To:Re:输入1(或-1)是多少? Posted by:realmajia at 2005-01-30 20:32:44
Why WA?
my code:

var
  n,k,s:longint;
  p,i:integer;
  f,y:boolean;
begin
  readln(n);
  while n<>0 do
    begin
      f:=false;
      p:=33;
      if n<0 then
        begin
          n:=-n;
          f:=true;
        end;
      y:=false;
      repeat
        dec(p);
        k:=round(exp((1/p)*ln(n)));
        s:=1;
        for i:=1 to p do s:=s*(k-1);
        if s=n then y:=true;
        s:=1;
        for i:=1 to p do s:=s*k;
        if s=n then y:=true;
        s:=1;
        for i:=1 to p do s:=s*(k+1);
        if s=n then y:=true;
      until ((y)and(not f))or((y)and(f)and(p mod 2=1))or(p=1);
      writeln(p);
      readln(n);
    end;
end.

I think it's right!

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