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

不知道哪错了...............哪位大牛看看啊

Posted by 1993623 at 2009-07-31 18:26:58 on Problem 3100
Program lostcity;
Const
  infile = 'pow1.in';
  outfile = 'pow1.out';
Var
  num:Array [1..1000] of Longint;
  pow:Array [1..1000] of Integer;
  b,i,mid1,count,count1,j,k:longint;
  ans,ans1,ans2,ans11,ans12,a:Longint;
Begin
  Assign(input,infile);
  Assign(output,outfile);
  Reset(input);
  Rewrite(output);
  a:=-1;
  b:=-1;
  count:=0;
  While((a<>0)and(b<>0))do begin
    Readln(a,b);
    if ((a=0)and(b=0)) then break;
    Inc(count);
    num[count]:=a;pow[count]:=b;
  end;
  For i:=1 to count do begin
    if num[i]<pow[i] then begin
      Writeln(1);
      Close(input);Close(output);halt;
    end;
    For j:=1 to 1000 do begin
      ans:=j;
      For k:=1 to pow[i]-1 do
        ans:=ans*j;
      if ans>=num[i] then begin mid1:=j; break;end;
      end;
    ans1:=1;ans2:=1;
    For j:=1 to pow[i] do ans1:=ans1*(mid1-1);
    For j:=1 to pow[i] do ans2:=ans2*mid1;
    ans11:=abs(ans1-num[i]);
    ans12:=abs(ans2-num[i]);
    if ans-num[i]=0 then Writeln(mid1)
    else if ans11>ans12 then Writeln(mid1)
    else Writeln(mid1-1);
  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