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:测试都过了,但是wa!!!!

Posted by hfcxb at 2008-04-15 19:26:32 on Problem 1565
In Reply To:测试都过了,但是wa!!!! Posted by:kuangwenkui at 2007-06-16 19:40:11
Mid-USA'1997的标程,是用Pascal语言写的。

program skew_binary;

var
  skew: string;


function digit (c: char): longint;
begin
  case c of
    '0': digit := 0;
    '1': digit := 1;
    '2': digit := 2;
  end
end;


function translate (s: string): longint;
var
  i: integer;
  n: longint;
  power_of_2: longint;
begin
  n := 0;
  power_of_2 := 2;
  for i := length(s) downto 1 do begin
    n := n + digit(s[i])*(power_of_2 - 1);
    power_of_2 := power_of_2 * 2;
  end;
  translate := n;
end;


begin
  repeat
    readln (skew);
    if skew <> '0' then writeln (translate (skew));
  until skew = '0';
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