- 卡布列克圆舞曲
- 2013-03-03 00:08:54 @
评测结果
上海红茶馆 via libjudge
编译成功
测试数据 #0: RuntimeError, time = 15 ms, mem = 1156 KiB, score = 0
测试数据 #1: RuntimeError, time = 15 ms, mem = 1156 KiB, score = 0
测试数据 #2: RuntimeError, time = 15 ms, mem = 1156 KiB, score = 0
测试数据 #3: RuntimeError, time = 30 ms, mem = 1156 KiB, score = 0
测试数据 #4: RuntimeError, time = 15 ms, mem = 1156 KiB, score = 0
测试数据 #5: RuntimeError, time = 15 ms, mem = 1156 KiB, score = 0
测试数据 #6: RuntimeError, time = 0 ms, mem = 1156 KiB, score = 0
测试数据 #7: RuntimeError, time = 0 ms, mem = 1156 KiB, score = 0
测试数据 #8: RuntimeError, time = 0 ms, mem = 1156 KiB, score = 0
测试数据 #9: Accepted,=== time = 15 ms, mem = 1156 KiB, score = 10
Summary: RuntimeError, time = 120 ms, mem = 1156 KiB, score = 10
代码:
type arraytype=array[0..9]of longint;
var
n:array[0..100000]of longint;
i,j,d:longint;
function max(a:arraytype):longint; //求重组后最大值
var
i,k:longint;
ans:longint;
begin
ans:=0; k:=0;
for i:=9 downto 0 do
while a[i]>0 do
begin
dec(a[i]);
ans:=ans*10+i;
inc(k);
end;
for i:=k+1 to d do ans:=ans*10;
exit(ans);
end;
function min(a:arraytype):longint; //求重组后最小值
var
i:longint;
ans:longint;
begin
ans:=0;
for i:=0 to 9 do
while a[i]>0 do
begin
dec(a[i]);
ans:=ans*10+i;
end;
exit(ans);
end;
function f(x:longint):longint; //一次重组操作
var
num:arraytype;
i,j:longint;
begin
fillchar(num,sizeof(num),0);
while x>0 do
begin
inc(num[x mod 10]);
x:=x div 10;
end;
exit(max(num)-min(num));
end;
procedure main(x:longint); //主函数,求卡布列克数列并输出
var
p:array[1..100000] of 0..1;
sign:longint;
begin
fillchar(p,sizeof(p),0);
p[x mod 100000]:=1;
x:=f(x);
while p[x mod 100000]=0 do
begin
p[x mod 100000]:=1;
x:=f(x);
end;
sign:=x;
write(x);
x:=f(x);
while x<>sign do
begin
write(' ',x);
x:=f(x);
end;
writeln;
end;
function dig(x:longint):longint; //求位数
var
i:longint;
begin
i:=0;
while x>0 do
begin
inc(i);
x:=x div 10;
end;
exit(i);
end;
begin //主程序
//assign(input,'P1024.in');reset(input);
//assign(output,'P1024.out');rewrite(output);
{i:=0;
while not eof do
begin
inc(i);
readln(n[i]);
end;
j:=i;
for i:=1 to j do
begin
d:=dig(n[i]);
main(n[i]);
end;}
main(0);
//close(input);close(output);
end.
求解释!!
7 条评论
-
朱天齐 LV 9 @ 2013-07-10 20:37:53
ME TOO!!
program vijos;
var
b,a:array[1..50]of byte;
hash:array[1..50]of int64;
i,j,top:longint;
p,q:int64;
st:ansistring;
{----------------------------------------------------------------------}
procedure sortA;
var
i,j,temp:longint;
begin
for i:=1 to length(st)-1 do
for j:=i+1 to length(st) do if b[i]<b[j] then begin
temp:=b[i];
b[i]:=b[j];
b[j]:=temp;
end;
end;procedure sortB;
var
i,j,temp:longint;
begin
for i:=1 to length(st)-1 do
for j:=i+1 to length(st) do if a[i]>a[j] then begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
end;
end;function pan(p:longint):longint;
var
i:longint;
begin
for i:=1 to top do if hash[i]=p then exit(i);
exit(0);
end;
{----------------------------------------------------------------------}
procedure Init;
begin
while not eof do begin
readln(p);
str(p,st);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(hash,sizeof(hash),0);
top:=0;
repeat
inc(top);
hash[top]:=p;
str(p,st);
p:=0;
q:=0;
for i:=1 to length(st) do begin
b[i]:=ord(st[i])-48;
a[i]:=b[i];
end;
sortA;
for i:=1 to length(st) do p:=p*10+b[i];
sortB;
for i:=1 to length(st) do q:=q*10+a[i];
p:=p-q;
until pan(p)<>0;
for i:=pan(p) to top do write(hash[i],' ');
writeln;
end;
end;
{----------------------------------------------------------------------}
BEGIN
Init;
END. -
2013-03-08 20:18:23@
没人看吗?我已经重发代码了……
建议VIJOS增加对修改已发贴的支持…… -
2013-03-03 12:11:10@
发的是测试时的代码………………
重发下提交的代码……
type arraytype=array[0..9]of longint;var
n:array[0..100000]of longint;
i,j,d:longint;function max(a:arraytype):longint;
var
i,k:longint;
ans:longint;
begin
ans:=0; k:=0;
for i:=9 downto 0 do
while a[i]>0 do
begin
dec(a[i]);
ans:=ans*10+i;
inc(k);
end;
for i:=k+1 to d do ans:=ans*10;
exit(ans);
end;function min(a:arraytype):longint;
var
i:longint;
ans:longint;
begin
ans:=0;
for i:=0 to 9 do
while a[i]>0 do
begin
dec(a[i]);
ans:=ans*10+i;
end;
exit(ans);
end;function f(x:longint):longint;
var
num:arraytype;
i,j:longint;
begin
fillchar(num,sizeof(num),0);
while x>0 do
begin
inc(num[x mod 10]);
x:=x div 10;
end;
exit(max(num)-min(num));
end;procedure main(x:longint);
var
p:array[1..100000] of 0..1;
sign:longint;
begin
fillchar(p,sizeof(p),0);
p[x mod 100000]:=1;
x:=f(x);
while p[x mod 100000]=0 do
begin
p[x mod 100000]:=1;
x:=f(x);
end;
sign:=x;
write(x);
x:=f(x);
while x<>sign do
begin
write(' ',x);
x:=f(x);
end;
writeln;
end;function dig(x:longint):longint;
var
i:longint;
begin
i:=0;
while x>0 do
begin
inc(i);
x:=x div 10;
end;
exit(i);
end;begin
//assign(input,'P1024.in');reset(input);
//assign(output,'P1024.out');rewrite(output);
i:=0;
while not eof do
begin
inc(i);
readln(n[i]);
end;
j:=i;
for i:=1 to j do
begin
d:=dig(n[i]);
main(n[i]);
end;
//close(input);close(output);
end. -
2013-03-03 12:09:14@
哦天哪……忘记删大括号了…………糗- -lll
-
2013-03-03 11:22:04@
没读入+10086
-
2013-03-03 10:52:24@
好像什么都没读= =
-
2013-03-03 09:56:26@
我咋觉得这个程序啥都没读入。。。
- 1