zoukankan      html  css  js  c++  java
  • Codeforces Round #326 (Div. 2) B Duff in Love 简单数论 姿势涨

    B. Duff in Love
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer a > 1 such that a2 is a divisor of x.

    Malek has a number store! In his store, he has only divisors of positive integer n (and he has all of them). As a birthday present, Malek wants to give her a lovely number from his store. He wants this number to be as big as possible.

    Malek always had issues in math, so he asked for your help. Please tell him what is the biggest lovely number in his store.

    Input

    The first and only line of input contains one integer, n (1 ≤ n ≤ 1012).

    Output

    Print the answer in one line.

    Sample test(s)
    Input
    10
    Output
    10
    Input
    12
    Output
    6
    Note

    In first sample case, there are numbers 1, 2, 5 and 10 in the shop. 10 isn't divisible by any perfect square, so 10 is lovely.

    In second sample case, there are numbers 1, 2, 3, 4, 6 and 12 in the shop. 12 is divisible by 4 = 22, so 12 is not lovely, while 6 is indeed lovely.


    题意:给一个数n  然你找到最大的一个数x    x满足两个条件 1.是n的因子 2.x不能整除 任何正整数的平方

    a题水果  看到这题 蒙蔽了 敲了一边 果然超时!!!打我呀?? 还不如不敲

    补一下姿势   将n分解素因子得到n  =p1^k1*p2^k2*…pm^km  例如   12=2^2*3^1

    举一个例子 模拟一边 给将来 自己看

     12 的因子 1 2 3 4 6 12

     12=2^2*3^1

     从2-->sqrt(12)=3

      12%(2*2)==0-->n=12/2=6-->

      6%(2*2)!=0->

      i++-->3

      3>sqrt(6)

     break;

    !!!!!sqrt(n)是为了保证素因子!!!

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        __int64 n;
        scanf("%I64d",&n);
        for(__int64 i=2;i<=sqrt(n);i++)
        {
            while(n%(i*i)==0)
                  n=n/i;
        }
        printf("%I64d
    ",n);
        return 0;
    }
    

                

  • 相关阅读:
    spark调度器FIFO,FAIR
    elasticsearch5.6.8 创建TransportClient工具类
    elasticsearch TransportClient bulk批量提交数据
    java 参数来带回方法运算结果
    idea上传代码到git本地仓库
    2020-03-01 助教一周小结(第三周)
    2020-02-23 助教一周小结(第二周)
    2020-02-16 助教一周小结(第一周)
    寻找两个有序数组的中位数
    无重复字符的最长子串
  • 原文地址:https://www.cnblogs.com/hsd-/p/4948356.html
Copyright © 2011-2022 走看看