得分越来越低了

var m,n,i,l1,l2:longint;

a:array[1..1000000] of 0..1;

str0:string;

function sushu(i:longint):boolean;

var j:longint;

begin

sushu:=true;

for j:=2 to trunc(sqrt(i)) do

if (i mod j=0) and (i2) then begin sushu:=false; exit; end;

if i=1 then sushu:=false;

end;

procedure huiwen;

var i,k,p,q,j:longint;

str0,str1:string;

begin

fillchar(a,sizeof(a),0);

for i:=trunc(exp(((l1+1) div 2-1)*ln(10))) to trunc(exp(((l2+1) div 2-1)*ln(10))) do

begin

str0:='';

str(i,str0);

for j:=1 to length(str0) do str1:=str1+str0[length(str0)-j+1];

val(concat(str0,str1),q); a[q]:=1; str1:='';

for j:=1 to length(str0)-1 do str1:=str1+str0[length(str0)-j];

val(concat(str0,str1),q); a[q]:=1; str1:='';

end;

end;

begin

readln(m,n);

str(m,str0); l1:=length(str0);

str(n,str0); l2:=length(str0);

huiwen;

for i:=m to n do

if a[i]=1 then if sushu(i) then writeln(i);

end.

2 条评论

  • @ 2009-10-30 22:12:23

    终于知道了

    原来判断的时候q有可能等于m,或等于n

    结果很奇怪的发现,开大搜索范围,一直都是

    编译通过...

    ├ 测试数据 01:答案错误...程序输出比正确答案长

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:运行超时|无输出...

    ├ 测试数据 07:答案错误...程序输出比正确答案长

    ├ 测试数据 08:答案错误... ├ 标准行输出

     ├ 错误行输出

    ├ 测试数据 09:运行超时|无输出...

    ├ 测试数据 10:答案错误...程序输出比正确答案长

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:40 有效耗时:0ms

    都交了十几次了

  • @ 2009-10-30 22:00:25

    再改一次

    var m,n,i,j,l1,l2,s:longint;

    a:array[0..100000] of longint;

    str0:string;

    function sushu(i:longint):boolean;

    var j:longint;

    begin

    for j:=2 to i do

    if j*j>i then exit(true) else

    if (i mod j=0) and (i2) then exit(false);

    exit(true);

    end;

    procedure huiwen;

    var i,k,p,q,j:longint;

    str0,str1:string;

    begin

    fillchar(a,sizeof(a),0);

    for i:=trunc(exp(((l1+1) div 2-1)*ln(10))) div 10

    to 20*trunc(exp(((l2+1) div 2-1)*ln(10))) do

    begin

    str(i,str0);

    str1:='';

    for j:=1 to length(str0) do str1:=str1+str0[length(str0)-j+1];

    val(concat(str0,str1),q); str1:='';

    if (q>m)and(qm)and(qa[j] then

    begin

    a[0]:=a[i];

    a[i]:=a[j];

    a[j]:=a[0];

    end;

    for i:=1 to s do

    writeln(a[i]);

    end.

  • 1

信息

ID
1042
难度
7
分类
搜索 | 搜索与剪枝 点击显示
标签
(无)
递交数
6583
已通过
1516
通过率
23%
被复制
13
上传者