- 进制转换
- 2012-10-29 16:22:46 @
VijosNT Mini 2.0.5.7 Special for Vijos
编译通过...
├ 测试数据 01:答案正确... (0ms, 784KB)
├ 测试数据 02:答案正确... (0ms, 784KB)
├ 测试数据 03:答案错误... (0ms, 784KB)
├ 测试数据 04:答案错误... (0ms, 784KB)
├ 测试数据 05:答案错误... (0ms, 784KB)
├ 测试数据 06:答案错误... (125ms, 784KB)
├ 测试数据 07:答案错误... (0ms, 784KB)
├ 测试数据 08:答案错误... (0ms, 784KB)
├ 测试数据 09:答案错误... (0ms, 784KB)
├ 测试数据 10:答案错误... (0ms, 748KB)
---|---|---|---|---|---|---|---|-
Unaccepted / 20 / 0ms / 784KB
view sourceprint?01 var
02 r:real;
03 s,m,x:ansistring;
04 i,j,l:longint;
05 a:array[0..10000] of integer;
06 b:array[0..10000] of real;
07 begin
08 readln(s);
09 for i:=1 to length(s) do
10 if s[i]='(' then break;
11 m:=copy(s,1,i-1);
12 s:=copy(s,i+1,length(s)-i-1);
13 x:=m;
14 for i:=1 to 15 div length(s)+1 do
15 m:=m+s;
16 val(m,r);
17 i:=0;
18 j:=0;
19 a[0]:=0;
20 b[0]:=r;
21 repeat
22 r:=r*2;
23 i:=i+1;
24 if r>1 then begin r:=r-1; a[i]:=1; end else a[i]:=0;
25 b[i]:=r;
26 for l:=0 to i-1 do
27 if abs(b[i]-b[l])
1 条评论
-
lfz960804 LV 10 @ 2012-10-29 17:17:03
80分
var
s,m:ansistring;
i,j,l:longint;
p1,p2,k1,k2,r,f,n1,n2,n:int64;
a,b:array[0..10000] of integer;
begin
readln(s);
for i:=1 to length(s) do
if s[i]='(' then break;
m:=copy(s,3,i-3);
s:=copy(s,i+1,length(s)-i-1);
p1:=length(m);
p2:=length(s);
n1:=1;
n2:=1;
n:=1;
val(m,k1);
val(s,k2);
for i:=1 to p1 do
n1:=n1*10;
for i:=1 to p2 do
n2:=n2*10;
for i:=1 to p1+p2 do
n:=n*10;
r:=n2*k1+k2-k1;
f:=n-n1;
i:=0;
j:=0;
a[0]:=0;
b[0]:=r;
repeat
r:=r*2;
i:=i+1;
a[i]:=r div f;
r:=r mod f;
b[i]:=r;
for l:=0 to i-1 do
if b[i]=b[l] then break;
until (b[i]=b[l]);
write('0.');
for j:=1 to l do
write(a[j]);
write('(');
for j:=l+1 to i do
write(a[j]);
writeln(')');
end.
- 1