zoukankan      html  css  js  c++  java
  • 最多约数问题

    暴力。

    #include"iostream"
    #include"stdio.h"
    #include"cmath"
    using namespace std;
    int  judge(int fac,int num)
    {
        int i;
        for(i=1;i<sqrt(num+0.0);i++)
        {
            if(num%i==0) fac+=2;
        }
        if(i==sqrt(num+0.0)) fac++;
        return fac;
    }
    
    int main()
    {
        freopen("E:\in.txt","r",stdin);
        freopen("E:\out.txt","w",stdout);
        int a,b;
        while(scanf("%d%d",&a,&b)==2)
        {
            int i,fac_num,max_num=0,num=a;
            for(i=a;i<=b;i++)
            {
                fac_num=judge(0,i);
                if(fac_num>max_num)
                {
                    max_num=fac_num;
                    num=i;
                }
            }
            cout<<max_num<<endl;
        }
        return 0;
    }
    View Code
  • 相关阅读:
    SCUT
    SCUT
    SCUT
    ???
    Codeforces
    SCUT
    SCUT
    SCUT
    SCUT
    2019牛客暑期多校训练营(第八场)
  • 原文地址:https://www.cnblogs.com/acm-jing/p/4788238.html
Copyright © 2011-2022 走看看