题解

67 条题解

  • 0
    @ 2013-10-04 21:03:49

    var n:int64;
    z1:longint;
    BEGIN
    readln(n);
    for z1:=2 to trunc(sqrt(n)) do
    If n mod z1=0 then
    begin
    writeln(n div z1);
    break;
    end;
    END.

  • 0
    @ 2013-09-08 15:06:20

    Block code

    var i,n:longint;
    begin
    read(n);
    for i:=2 to round(sqrt(n)) do
    if n mod i=0 then
    begin
    write(n div i);
    exit;
    end;
    end.

  • 0
    @ 2013-09-08 15:01:19

    这数据也太水了吧

  • 0
    @ 2013-08-12 16:07:11

    我现在才知道,原来**不要判断素数**。。。。
    发一个丑陋的代码:
    var i,n:longint;
    function prime(p:longint):boolean;var i:longint;
    begin
    prime:=true;if p=2 then exit(true);
    for i:=2 to trunc(sqrt(p)) do if p mod i=0 then exit(false);
    end;begin readln(n);
    for i:=2 to trunc(sqrt(n)) do
    if (prime(i)) and (n mod i=0) then begin write(n div i);break;end;
    end.
    感觉挺短,但一比较就。。。orz各位犇了

  • 0
    @ 2013-07-31 10:30:29

    var q,n,p,i:longint;
    begin
    readln(n);
    for i:=2 to n div 2 do
    if n mod i=0 then
    begin
    q:=i;
    break;
    end;
    p:=n div q;
    writeln(p);
    end.

  • 0
    @ 2013-07-25 14:29:18

    #include<iostream>
    #include<cmath>
    int main()
    {
    using namespace std;
    long long n,p;
    cin >> n;
    p=2;
    while(n%p!=0){
    p++;
    }
    p=n/p;
    cout << p;
    return 0;
    }

  • 0
    @ 2013-07-19 20:05:23

    var n,i:longint;
    begin
    readln(n);
    for i:=2 to n div 2 do
    if n mod i=0 then
    begin
    writeln(n div i);
    halt;
    end;
    end.

    i循环需要到n么。。。。水军大战

  • 0
    @ 2013-07-11 10:22:27

    const
    maxn=45000;
    var
    su:array[1..maxn] of boolean;
    n,i,j:longint;
    begin
    readln(n);
    fillchar(su,sizeof(su),true);
    su[1]:=false;
    for i:=2 to trunc(sqrt(maxn)) do
    if su[i] then
    for j:=2 to maxn div i do su[i*j]:=false;
    for i:=2 to trunc(sqrt(n)) do
    if (su[i]=true) and (n mod i=0) then
    begin writeln(n div i); break; end;
    end.

  • 0
    @ 2013-06-18 22:24:24

    测试数据 #0: Accepted, time = 0 ms, mem = 736 KiB, score = 10

    测试数据 #1: Accepted, time = 0 ms, mem = 736 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 736 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 736 KiB, score = 10

    测试数据 #5: Accepted, time = 0 ms, mem = 736 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #8: Accepted, time = 15 ms, mem = 736 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    program xx;
    var i,n:longint;
    begin
    read(n);
    for i:=2 to n do if n mod i=0 then begin write(n div i);exit; end;
    end.
    需要那么麻烦么?

  • 0
    @ 2013-06-16 16:15:49

    VijosEx via JudgeDaemon2/13.6.5.0 via libjudge

    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #1: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 736 KiB, score = 10

    测试数据 #4: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #5: Accepted, time = 3 ms, mem = 736 KiB, score = 10

    测试数据 #6: TimeLimitExceeded, time = 1014 ms, mem = 736 KiB, score = 0

    测试数据 #7: Accepted, time = 15 ms, mem = 732 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 732 KiB, score = 10

    测试数据 #9: Accepted, time = 3 ms, mem = 740 KiB, score = 10

    TimeLimitExceeded, time = 1035 ms, mem = 740 KiB, score = 90

    怎么会这样

  • 0
    @ 2013-05-05 14:01:26

    var
    a,b,c,d,k:longint;
    begin
    {assign(input,'prime.in');
    reset(input);
    assign(output,'prime.out');
    rewrite(output);}
    read(a);
    for b:=2 to a do
    if a mod b=0 then
    begin
    k:=0;
    for c:=2 to trunc(sqrt(b)) do
    if b mod c=0 then begin k:=1;break;end;
    if k=0 then begin write(a div b);break;end;
    end;
    {close(input);
    close(output);}
    end.

  • 0
    @ 2012-11-24 18:25:25

    NOIP普及组 T1 分解质因数(8行代码+解析)

    有一个关键点………………

    http://user.qzone.qq.com/1057586889/blog/1353143825

  • 0
    @ 2012-11-22 17:12:46

    program prime;

    var

    a,b,c,d,k:longint;

    begin

    {assign(input,'prime.in');

    reset(input);

    assign(output,'prime.out');

    rewrite(output);}

    read(a);

    for b:=2 to a do

    if a mod b=0 then

    begin

    k:=0;

    for c:=2 to trunc(sqrt(b)) do

    if b mod c=0 then begin k:=1;break;end;

    if k=0 then begin write(a div b);break;end;

    end;

    {close(input);

    close(output);}

    end.

    源程序

  • 0
    @ 2012-11-21 19:37:41

    ├ 测试数据 01:答案正确... (0ms, 672KB)

    ├ 测试数据 02:答案正确... (15ms, 672KB)

    ├ 测试数据 03:答案正确... (15ms, 672KB)

    ├ 测试数据 04:答案正确... (0ms, 672KB)

    ├ 测试数据 05:答案正确... (0ms, 672KB)

    ├ 测试数据 06:答案正确... (15ms, 672KB)

    ├ 测试数据 07:答案正确... (15ms, 672KB)

    ├ 测试数据 08:答案正确... (0ms, 672KB)

    ├ 测试数据 09:答案正确... (15ms, 672KB)

    ├ 测试数据 10:答案正确... (15ms, 672KB)

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

    Accepted / 100 / 93ms / 672KB

    今年的普及组水题

  • 0
    @ 2012-11-21 16:39:59

    居然不是沙发

  • 0
    @ 2012-11-21 13:01:50

    此题的样例貌似输错了。。。

  • -1
    @ 2018-08-08 19:57:01

    我这个Pascal是最省时的,因为我就是无极剑圣,速度天下第一!!!!
    var
    n,i,max,k:longint;
    function f(n:longint):boolean;
    var i:longint;
    begin
    f:=true;
    for i:=2 to trunc(sqrt(n)) do
    if n mod i=0 then begin f:=false;break;end;
    end;
    begin
    max:=-maxlongint;
    read(n);
    k:=n;
    for i:=1 to trunc(sqrt(k)) do
    if (n mod i=0) and (n div i>max) and (f(n div i)=true) then max:=n div i;
    write(max);
    end.

  • -1
    @ 2017-10-15 15:26:51

    var
    n,i:longint;

    begin
    read(n);
    for i:=2 to n do
    if (n mod i=0) then
    begin
    write(n div i);
    exit;
    end;
    end.

  • -1
    @ 2017-07-08 14:58:43
    #include <cstdio>
    #include <iostream>
    
    
    using namespace std;
    
    int main(){
        int num;
        cin >> num;
        for (int i = 2; i < num / 2 + 1; i++){
            if (num % i == 0){
                cout << num / i << endl;
                break;
            }
        }
        return 0;
    }
    

信息

ID
1786
难度
5
分类
搜索 | 搜索 | 枚举 点击显示
标签
递交数
4997
已通过
1915
通过率
38%
被复制
21
上传者