Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:测试都过了,但是wa!!!!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator