题解

138 条题解

  • 0
    @ 2009-09-24 18:01:25

    一次就秒杀了,就是爽,!!水题就是水!

    #include

    using namespace std;

    int n,nk[20000];

    int mm, result = 0,last = 1;

    void mul(int n)

    {

    int i, j, total = 0, past = 0;

    for(i = 1; i 0)

    {

    nk[++last] = past % 10;

    past /= 10;

    }

    }

    bool work(long long a)

    {

    int i, j;

    if(a < 2)

    return false;

    if(a == 2)

    return true;

    for(i = 2;i*i < a; i++)

    if(a % i == 0)

    return false;

    return true;

    }

    int init()

    {

    scanf("%d",&n);

    }

    int jc()

    {

    int i,j;

    for(i = n; i >= 2; i --)

    mul(i);

    for(i = 1; i 0)

    {

    result += (nk[i] % 10);

    nk[i] /= 10;

    }

    }

    }

    int outit()

    {

    if(work(result))

    cout

  • 0
    @ 2009-09-03 16:47:00

    var

    i,j,k,l,n:longint;

    a:array[1..1000,1..2000] of integer;

    begin

    readln(n);

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

    a[1,2000]:=1;

    for i:= 2 to n do

    begin

    k:=0;

    for j:= 2000 downto 1 do

    begin

    k:=k+a*i;

    a:=k mod 10;

    k:=k div 10;

    end;

    end;

    k:=0;

    for i:= 1 to 2000 do

    k:=k+a[n,i];

    write(k);

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

    if k mod i=0 then

    begin

    write('F');

    halt;

    end;

    write('T');

    end.

    1次AC

  • 0
    @ 2009-08-28 21:09:40

    高精度乘单精度

    水题!!

  • 0
    @ 2009-08-28 13:32:08

    program zhjh;

    var

    n,len,x,i,j:longint;

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

    begin

    readln(n);

    len:=1;

    for i:=1 to 10000 do

    a[i]:=1;

    for i:=1 to n do begin

    x:=0;

    for j:=1 to len do begin

    a[j]:=a[j]*i+x;

    x:=a[j] div 10;

    a[j]:=a[j] mod 10;

    end;

    while x>0 do begin

    len:=len+1;

    a[len]:=x mod 10;

    x:=x div 10;

    end;

    end;

    x:=0;

    for i:=len downto 1 do

    x:=x+a[i];

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

    if x mod i=0 then begin writeln(x,'F'); exit; end;

    writeln(x,'T');

    end.

    end.

    会做阶乘,就会做这个

  • 0
    @ 2009-08-27 10:49:03

    var a:array[0..5000]of integer;

    i,j,n:integer;s:longint;

    k:boolean;

    begin

    read(n);

    for i:=0 to 5000 do

    a[i]:=0;

    a[1]:=1;

    for i:=1 to n do

    for j:=1 to 5000 do

    begin

    a[j]:=a[j]*i;

    a[j]:=a[j]+(a[j-1] div 10);

    a[j-1]:=a[j-1] mod 10;

    end;

    s:=0;

    for i:=1 to 5000 do

    s:=s+a[i];

    k:=false;

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

    if (s mod i)=0 then k:=true;

    if k=true then write(s,'F');

    if k=false then write(s,'T');

    end.

  • 0
    @ 2009-08-25 17:42:03

    var

    a:array[1..10000]of longint;

    ans,i,j,k,n,l,len:longint;

    ss:string;

    function check(v:longint):boolean;

    var i:longint;

    begin

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

    if v mod i=0 then exit(false);

    exit(true);

    end;

    procedure cheng(v:longint);

    var i:longint;

    begin

    for i:=1 to len do

    a[i]:=a[i]*v;

    for i:=1 to len do

    begin

    a:=a+a[i] div 10000;

    a[i]:=a[i] mod 10000;

    end;

    while a[len]0 do inc(len);

    end;

    begin

    readln(n);

    a[1]:=1;len:=1;

    for i:=2 to n do cheng(i);

    ans:=0;

    for i:=1 to len do

    begin

    str(a[i],ss);

    for j:=1 to length(ss) do

    begin

    val(ss[j],k);

    inc(ans,k);

    end;

    end;

    write(ans);

    if check(ans) then writeln('T')

    else writeln('F');

    end.

  • 0
    @ 2009-08-21 22:01:58

    var y,p,k,n,lenc,len1,len2,x,i,j,t:longint;

    s:string;

    a,b,c:array[0..1000] of integer;

    function zs(q:integer):boolean;

    var d:integer;

    begin

    zs:=true;

    if q=1 then begin zs:=false; exit; end;

    if q=0 then begin zs:=false; exit; end;

    for d:=2 to round(sqrt(q)) do

    if q mod d=0 then

    begin

    zs:=false;

    exit;

    end;

    end;

    begin

    readln(n);

    s:='1';

    for k:=1 to n do

    begin

    fillchar(c,sizeof(c),0);

    y:=k;

    len1:=length(s);

    if y=10) and (k=100) and (k1) do dec(lenc);

    s:='';

    for i:=lenc downto 1 do s:=s+chr(c[i]+48);

    end;

    for i:=1 to lenc do

    t:=t+c[i];

    write(t); if zs(t) then writeln('T')

    else writeln('F');

    end.

  • 0
    @ 2009-08-20 17:46:47

    编译通过...

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

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

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

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

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

    Accepted 有效得分:100 有效耗时:0ms

    var

    n,i,j,k:longint;

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

    begin

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

    a[1]:=1;

    k:=1;

    readln(n);

    for i:=2 to n do

    begin

    a[1]:=a[1]*i;

    for j:=2 to k do

    begin

    a[j]:=a[j]*i+a[j-1] div 10;

    a[j-1]:=a[j-1] mod 10;

    end;

    while a[k]>=10 do

    begin

    inc(k);

    a[k]:=a[k]+a[k-1] div 10;

    a[k-1]:=a[k-1] mod 10;

    end;

    end;

    j:=0;

    for i:=1 to k do

    j:=j+a[i];

    write(j);

    if j=2 then

    begin

    writeln('T');

    halt;

    end;

    k:=round(sqrt(j));

    for i:=1 to k do

    if j mod i=0 then

    begin

    writeln('F');

    halt;

    end;

    writeln('T');

    end.

    Flag    Accepted

    题号   P1200

    类型(?)   其它

    通过   2214人

    提交   4513次

    通过率   49%

    难度   1

    提交 讨论 题解

  • 0
    @ 2009-08-17 10:19:30

    program Project1;

    var a,b,c,s,d,i:integer;

    t:boolean;

    begin

    readln(a);

    s:=1;

    t:=true;

    for i:=1 to a do

    s:=s*i;

    begin

    问一下,怎么分解各个位并相加?????

    谢谢!

    d:=b+c;

    end;

    for i:=1 to trunc(sqrt(d)) do

    if d mod i=0 then t:=false;

    write(d);

    if t then write('T')else write('F');

    readln;

    readln;

    end.

  • 0
    @ 2009-08-12 23:17:13

    5分钟秒杀!

    最快做法:

    直接用4位存储,好处多多~~~~ 写起来很短!

  • 0
    @ 2009-08-12 20:41:10

    编译通过...

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

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

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

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

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

    Accepted 有效得分:100 有效耗时:0ms

    水题一道

  • 0
    @ 2009-08-11 08:31:24

    高精乘+质素判断

    貌似不需要4位压

  • 0
    @ 2009-08-10 13:57:35

    var n,i,j,k,l:longint;

    s:string;

    a:array[1..100] of integer;

    begin

    readln(n);

    k:=1;

    for i:=2 to n do k:=k*i;

    str(k,s);

    l:=length(s);

    for i:=1 to l do a[i]:=ord(s[i])-48;

    k:=0;

    for i:=1 to l do k:=k+a[i];

    write(k);

    j:=1;

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

    if k mod i=0 then j:=0;

    if j=1 then writeln('T')

    else writeln('F');

    end.

  • 0
    @ 2009-08-09 10:34:58

    program lx;

    var

    n,i,c,y :longint;

    a,b :array[1..1000]of longint;

    f :array[1..1000]of boolean;

    j :longint;

    procedure add;

    var

    i :longint;

    begin

    i:=1;

    while f[i]=true do begin

    a[i]:=a[i]+b[i];

    if a[i]>9999 then begin

    a:=a+(a[i] div 10000);

    a[i]:=a[i] mod 10000;

    end;

    i:=i+1;

    end;

    fillchar(b,sizeof(b),0);

    end;

    begin

    readln(n);

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

    fillchar(f,sizeof(f),false);

    i:=1;

    a[1]:=1;

    f[1]:=true;

    while i9999 then begin

    b[j+1]:=a[j] div 10000;

    a[j]:=a[j] mod 10000;

    end;

    j:=j+1;

    end;

    add;

    i:=i+1;

    end;

    for i:=1 to 1000 do begin

    if f[i]true then begin c:=i-1; break; end;

    end;

    y:=0;

    for i:=1 to c do begin

    for j:=1 to 4 do begin

    y:=y+(a[i] mod 10);

    a[i]:=a[i] div 10;

    end;

    end;

    write(y,' ');

    if (n=2) or (n=5) then write('T')

    else write('F');

    end.

    高精度(必须用万进制,否则输出为零);

    另外,只有当n=2或5时为t。

  • 0
    @ 2009-08-06 21:50:51

    n太小,表打得都没意义……

  • 0
    @ 2009-08-05 00:06:54

    爽!一次编译通过,一次测试通过,一次ac

  • 0
    @ 2009-08-01 13:46:48

    AC100..在此庆祝下...

  • 0
    @ 2009-07-30 17:27:27

    type arr=array[0..10000]of longint;

    var n,i,sum,cheat:longint;

    a:arr;

    procedure muti(var a:arr; n:longint);

    var i,w:longint;

    begin

    w:=0;

    for i:=1 to a[0] do

    begin

    w:=w+a[i]*n;

    a[i]:=w mod 10000;

    w:=w div 10000;

    end;

    while w>0 do

    begin

    inc(a[0]);

    a[a[0]]:=w mod 10000;

    w:=w div 100000;

    end;

    end;

    function prime(n:longint):boolean;

    var i:longint;

    begin

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

    if n mod i=0 then exit(false);

    prime:=true;

    end;

    begin

    readln(n);

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

    a[0]:=1;

    a[1]:=1;

    sum:=0;

    for i:=2 to n do muti(a,i);

    for i:=1 to a[0] do

    begin

    while a[i]>0 do

    begin

    inc(sum,a[i] mod 10);

    a[i]:=a[i] div 10;

    end;

    end;

    if prime(sum) then write(sum,'T')

    else write(sum,'F');

    end.

    代码要写的干净,标准。

  • 0
    @ 2009-07-29 22:08:32

    硬做即可

    编译通过...

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

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

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

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

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

    Accepted 有效得分:100 有效耗时:0ms

    #include

    #include

    using namespace std;

    int a[2000]={0};

    main ()

    {

    a[0]=1;

    int s,d=0;

    cin>>s;

    for (int i=s;i>=2 && d==0;i--)

    {

    if (i

  • 0
    @ 2009-07-26 12:17:27

    没救了 没救啦。。。。

    天啊。。。

信息

ID
1200
难度
4
分类
数论 | 素数判定 点击显示
标签
(无)
递交数
3393
已通过
1348
通过率
40%
被复制
11
上传者