zoukankan      html  css  js  c++  java
  • CodeForces 588B

    题目链接 :

    http://codeforces.com/problemset/problem/588/B

    题目大意:

    这个题目的意思就是找出一个数中的因子,这个因子满足以下条件:

    1、此数的因子没有完全平方数

    2、是N中最大的因子

    解题思路:

    如果从1找到N,无疑会超时,所有我们只要从1到找sqrt(n)就好了,然后先判断从最大因子开始判断是否满足条件,若满足直接输出即可。

    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <iostream>
    using namespace std;
    #define LL long long
    
    
    LL sq[1000001];
    int  fun(LL x)
    {
       LL i;
       for(i=2;i*i<=x;i++)
         if(x%(i*i)==0) return 0;
       return 1;
    }
    
    LL ma(LL x,LL y)
    {
     if(x>y) return  x;
     else    return y;
    }
    
    int main()
    {
    
     LL i,j,n;
    
    while(cin>>n)
    {
    
     int flag=0;
     LL ans=1,m=sqrt(n+0.5)+1;
     for(i=1;i<=m;i++)
     {
        LL k=n/i;
        if(n%i==0&&fun(k))
           {
             flag=1;
             ans=k;
             break;
           }
     }
    
     if(!flag)
     for(i=m;i>=1;i--)
     {
    
        if(n%i==0&&fun(i))
           {
              ans=i;
              break;
            }
     }
    
    
     cout<<ans<<endl;
     }
     return 0 ;
     }
    

      

  • 相关阅读:
    图片音乐 上传、下载
    表格类型数据,Excel csv导入,导出操作
    逐行读取txt文件,分割,写入txt。。。上传,下载
    性能分析四
    性能分析三
    postman断言
    postman+Newman语法参数
    shell_03
    shell_02
    shell_01
  • 原文地址:https://www.cnblogs.com/www-cnxcy-com/p/5532651.html
Copyright © 2011-2022 走看看