193 条题解

  • 0
    @ 2009-07-03 08:44:54

    program exer1;

    var x0:2..100000;y0:2..1000000;

    p,q,t,a,b,i,temp:longint;

    yes:boolean;

    begin

    read(x0,y0);

    t:=2;

    if x0=y0 then t:=1

    else if (x0

  • 0
    @ 2009-06-28 17:25:39

    #include

    int t =0;

    long x0,y0;

    void swap(int &a,int &b)

    {

    int t;

    t=a;

    a=b;

    b=t;

    }

    int gys(int p,int q)

    {

    if(p>q)

    swap(p,q);

    if(q%p==0)

    {

    return p;

    }

    else

    {

    return gys(p,q%p);

    }

    }

    int main()

    {

    cin>>x0>>y0;

    for(int i=x0;i

  • 0
    @ 2009-05-23 22:09:04

    #include

    long count=0;

    void swap(long p,long q)

    {

    long t;

    t=p;

    p=q;

    q=t;

    }

    long gcd(long p,long q)

    {

    if(q==0) return p;

    else return gcd(q,p%q);

    }

    long lcm(long p,long q)

    {

    long i;

    if(p0) i+=p;

    return i;

    }

    int main()

    {

    long x0,y0;

    long p,q;

    scanf("%ld %ld",&x0,&y0);

    if(x0==y0){printf("1");return 0;}

    else{

    if(y0%x0!=0){printf("0");return 0;}

    else

    {

    for(p=x0;p

  • 0
    @ 2009-05-23 16:19:11

    编译通过...

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

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

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

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

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

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

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

    var

    x,y,p,q,ans,c:longint;

    function gcd(a,b:longint):longint;

    begin

    if b=0 then gcd:=a

    else gcd:=gcd(b,a mod b);

    end;

    begin

    readln(x,y);

    if(y mod x0) then write(0)

    else begin

    for p:=1 to y do

    begin

    if (p mod x=0)and (p mod p=0) then

    begin

    q:=x*y div p;

    c:=gcd(p,q);

    if (c=x)and(y mod p=0)and(y mod q=0) then begin inc(ans);end;

    end;

    end;

    write(ans);

    end;

    end.

  • 0
    @ 2009-04-29 14:36:59

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

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

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

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

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

    简单的水水

  • 0
    @ 2009-04-19 21:14:25

    编译通过...

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

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

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

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

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

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

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

    #include

    using namespace std;

    //最小公倍数用a*b=(a,b)*[a,b]的公式算就行了.

    long gcd2(long a,long b) //求最大公约数的方法

    {

    if(b==0)

    return a;

    else return gcd2(b,a%b);

    }

    long lcm2(long a, long b)//求最小公倍数的方法

    {

    return a*b/gcd2(a,b);

    }

    /*我们可以设变量i、j来控制两个数的的变化

    定义i、j循环时,一次要每次增加x0,否则会超时*/

    int main()

    {

    int x0,y0,i,j,sum=0;

    cin>>x0>>y0;

    for (i=x0;i

  • 0
    @ 2009-03-15 18:55:45

    so esay

    秒杀

    var

    p,q,a,b,s:qword;

    i:longint;

    begin

    readln(p,q);

    if p=q then

    begin

    writeln(1);

    exit;

    end;

    for i:=p to trunc(sqrt(p*q)) do

    if p*q mod i=0 then

    begin

    a:=i;

    b:=p*q div i;

    while (a mod b0)and(b mod a0) do

    begin

    if a>b then a:=a mod b

    else b:=b mod a;

    end;

    if (a mod b=p)or(b mod a=p) then inc(s);

    end;

    s:=s*2;

    writeln(s);

    end.

  • 0
    @ 2009-02-21 02:05:08

    不让贴程序,写些方法吧

    long gcd2(long a,long b) //求最大公约数的方法

    {

    if(b==0)

    return a;

    else

    return gcd2(b,a%b);

    }

    long lcm2(long a, long b)//求最小公倍数的方法

    {

    return a*b/gcd2(a,b);

    }

    我们可以设变量i、j来控制两个数的的变化

    定义i、j循环时,一次要每次增加x0,否则会超时:

    for(i=x0;i

  • 0
    @ 2009-02-08 10:43:24

    #include

    using namespace std;

    int sub(int m,int n)

    {

    int r;

    if(m>n) {r=m;m=n;n=r;}

    while(n!=0)

    {

    r=m;m=n;n=r%n;

    }

    return m;

    }

    int main()

    {

    double a,b,t,i,j;

    cin>>a>>b;

    if(a>b) {t=a;a=b;b=t;}

    t=0.0;

    for(i=a;i

  • 0
    @ 2009-02-05 20:18:57

    编译通过...

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

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

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

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

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

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

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

    p:=(y0-x0) div x0;

    for i:=1 to p+1 do

    for j:=1 to p+1 do

    if (gcd(i,j)=1)and(x0*i*j=y0) then inc(count);

  • 0
    @ 2009-01-17 11:08:34

    编译通过...

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

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

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

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

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

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

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

    Program fq01_p2; {2001分区联赛普及组第2题}

    var

    ans,x,y,z,p,k:longint;

    i:integer;

    begin

    readln(x,y);

    if(y mod x0)then

    begin

    writeln(0); {无解}

    exit;

    end;

    z := y div x;

    p:=2;

    k:=0;

    while(z>1) do

    begin

    if(z mod p=0) then

    begin

    inc(k);

    while(z mod p=0) do z:=z div p;

    end;

    inc(p);

    end;

    ans:=1; {计算ans=2^k}

    for i:=1 to k do

    ans:=ans*2;

    writeln(ans);

    end.

  • 0
    @ 2008-12-17 16:30:38

    if (p mod x0=0) and (y0 mod p=0) then

    begin

    q:=y0 div p * x0;

    if [判P,Q的最大公倍是否=X0] then inc(ans);

    end;

  • 0
    @ 2008-12-07 14:44:20

    编译通过...

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

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

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

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

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

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

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

    program p1131;

    var

    x0,y0,pq,ans:longint;

    function gcd(a,b:longint):longint;

    begin

    if b=0

    then exit(a)

    else exit(gcd(b,a mod b));

    end;

    begin

    readln(x0,y0);

    if y0 mod x00

    then begin

    writeln(0);

    halt;

    end;

    ans:=0;

    for pq:=1 to trunc(sqrt(y0 div x0)) do

    if (y0 div x0) mod pq=0

    then if gcd((y0 div x0) div pq,pq)=1

    then inc(ans,2);

    writeln(ans);

    end.

  • 0
    @ 2008-12-06 10:26:17

    囧……考虑出错了……我的AC率……ToT

    编译通过...

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

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

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

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

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

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

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

    function gcd(a,b:longint):longint;

    begin

    if b=0 then exit(a);

    exit(gcd(b,a mod b));

    end;

    var

    x,y,n,i,sum,k:longint;

    begin

    read(x,y);

    if (y mod x)0 then begin write(0); halt; end;

    sum:=0;

    n:=y div x;

    for i:=1 to trunc(sqrt(n))-1 do

    begin

    k:=gcd(n div i,i);

    if k=1 then

    if n mod i=0 then inc(sum,2);

    end;

    writeln(sum);

    end.

    Flag    Accepted

    题号   P1131

    类型(?)   数论 / 数值

    通过   2540人

    提交   5925次

    通过率   43%

    难度   1

    提交 讨论 题解

    编译通过...

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

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

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

     ├ 错误行输出

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

     ├ 错误行输出

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

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

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

    function gcd(a,b:longint):longint;

    begin

    if b=0 then exit(a);

    exit(gcd(b,a mod b));

    end;

    var

    x,y,n,i,sum,k:longint;

    begin

    read(x,y);

    sum:=0;

    n:=y div x;

    for i:=1 to trunc(sqrt(n))-1 do

    begin

    k:=gcd(n div i,i);

    if k=1 then

    if n mod i=0 then inc(sum,2);

    end;

    if n mod trunc(sqrt(n))=0 then

    begin

    inc(sum);

    if trunc(sqrt(n))*trunc(sqrt(n))n then inc(sum);

    end;

    writeln(sum);

    end.

    Flag    Unaccepted

    题号   P1131

    类型(?)   数论 / 数值

    通过   2539人

    提交   5924次

    通过率   43%

    难度   1

    提交 讨论 题解

  • 0
    @ 2008-11-22 12:26:05

    编译通过...

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

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

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

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

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

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

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

    ——这个方法是谁想的?大牛啊~

    {for p:=1 to y0 do if (p mod x0=0)and(y0 mod p=0) then

     begin

      q:=(y0 div p)*x0;(数学方法);

      if p,q的最大公约数为x0(可用一个函数判断) then inc(ans);(ans:答案)

    end;}

    var

    x0,y0,p,q:longint;

    ans:int64;

    function yes:boolean;

    var

    n,i:longint;

    begin

    if p>q then n:=p else n:=q;

    for i:=n downto x0+1 do

    if (p mod i=0)and(q mod i=0) then begin yes:=false; exit; end;

    if (p mod x0=0)and(q mod x0=0) then yes:=true;

    end;

    begin

    readln(x0,y0);

    ans:=0;

    for p:=1 to y0 do if (p mod x0=0)and(y0 mod p=0) then

    begin

    q:=(y0 div p)*x0;

    if yes then inc(ans);

    end;

    writeln(ans);

    end.

  • 0
    @ 2008-11-12 21:18:03

    编译通过...

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

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

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

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

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

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

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

  • 0
    @ 2008-11-12 12:13:33

    整死人了,哪晓得还有y0不能被x0整除的情况

  • 0
    @ 2008-11-11 20:11:10

    ac 40!!!!!感动中

  • 0
    @ 2008-11-07 18:59:52

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

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

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

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

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

    这题应该可以算是一题数学题吧

  • 0
    @ 2008-11-03 19:27:20

    编译通过...

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

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

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

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

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

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

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

最小公倍数和最大公约数问题

信息

ID
1131
难度
4
分类
其他 | 数学搜索 | 枚举 点击显示
标签
递交数
7297
已通过
2964
通过率
41%
被复制
24
上传者