1.每一个合数都可以由若干个素数相乘而得到
2.质因数知识 :求一个数因数的个数等于它的每个质因数的次数加一的和相乘的积
因为质因数可以不用,所以要加一.
例如6=2x3,两个质因数都是一次,如果两个质因数都不用,它的一个因数是1;只用因数2,它的第二个因数就是2;只用因数3,它的第三个因数就是3;两个质因数都用,它的第四个因数就是6。
所以6的因数的个数就是(1+1)(1+1)=4。
再如12=2²x3,两个质因数,2是2次,3是一次,如果两个质因数都不用,它的一个因数是1;只用一个因数2,它的第二个因数就是2;两个2都用,它的第三个因数就是4;不用3时就有3个因数,再用上3时就是(2+1)(1+1)=6个因数了。
然后下面这道题的答案就是每个质因数都只乘一次     10就是2x5。12就是2x3。
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.

Examples
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.

AC代码

 #include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;
const int maxn= ;
const int maxm= 1e4+;
const int inf = 0x3f3f3f3f;
typedef long long ll;
int main()
{
ll n;
while(scanf("%I64d",&n)!=EOF) //codeforces 不支持%lld
{
ll sum=;
for(int i=;i<=sqrt(n);i++) //要用sqrt函数 用i*i<=n 要把i定义为ll i*i会爆int
{
if(n%i==)
sum*=i;
while(n%i==) //除去倍数
n/=i;
}
printf("%I64d\n",sum*n);
}
return ;
}

Codeforces Round #326 (Div. 2) B的更多相关文章

  1. Codeforces Round #326 (Div. 2) D. Duff in Beach dp

    D. Duff in Beach Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/probl ...

  2. Codeforces Round #326 (Div. 2) C. Duff and Weight Lifting 水题

    C. Duff and Weight Lifting Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  3. Codeforces Round #326 (Div. 2) B. Duff in Love 分解质因数

    B. Duff in Love Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/proble ...

  4. Codeforces Round #326 (Div. 2) A. Duff and Meat 水题

    A. Duff and Meat Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/588/probl ...

  5. 很好的一个dp题目 Codeforces Round #326 (Div. 2) D dp

    http://codeforces.com/contest/588/problem/D 感觉吧,这道题让我做,我应该是不会做的... 题目大意:给出n,L,K.表示数组的长度为n,数组b的长度为L,定 ...

  6. 「日常训练」Duff in the Army (Codeforces Round #326 Div.2 E)

    题意(CodeForces 588E) 给定一棵\(n\)个点的树,给定\(m\)个人(\(m\le n\))在哪个点上的信息,每个点可以有任意个人:然后给\(q\)个询问,每次问\(u\)到\(v\ ...

  7. Codeforces Round #326 (Div. 2) B. Pasha and Phone C. Duff and Weight Lifting

    B. Pasha and PhonePasha has recently bought a new phone jPager and started adding his friends' phone ...

  8. Codeforces Round #326 (Div. 2)-Duff in Love

    题意: 一个数x被定义为lovely number需要满足这样的条件:不存在一个数a(a>1),使得a的完全平方是x的因子(即x % a2  != 0). 给你一个数n,求出n的因子中为love ...

  9. Codeforces Round #326 (Div. 2)-Duff and Meat

    题意: Duff每天要吃ai千克肉,这天肉的价格为pi(这天可以买好多好多肉),现在给你一个数值n为Duff吃肉的天数,求出用最少的钱满足Duff的条件. 思路: 只要判断相邻两天中,今天的总花费 = ...

随机推荐

  1. (转)iOS-Runtime知识点整理

    runtime简介 因为Objc是一门动态语言,所以它总是想办法把一些决定工作从编译连接推迟到运行时.也就是说只有编译器是不够的,还需要一个运行时系统 (runtime system) 来执行编译后的 ...

  2. Xftp连接阿里云Linux,向Linux上传文件,Windows和Linux文件传输

    我之前是用SecureCRT连接阿里云Linux的,上传文件用的Alt+p快捷键,感觉不是很方便.后来朋友给我推荐了Xshell,感觉确实好用得很多. 传输文件用的是Xftp,今天在向我的个人网站发布 ...

  3. 为什么要学ADO.NET。。。什么是ADO.NET。。。

    之前学的 •只能在查询分析器里查看数据,操作数据,我们不能让普通用户去学sql,所以我们搭建一个界面(Web Winform)让用户方便的操作数据库中的数据.   •ADO.NET就是一组类库,这组类 ...

  4. Apache Avro# 1.8.2 Specification (Avro 1.8.2规范)一

    h4 { text-indent: 0.71cm; margin-top: 0.49cm; margin-bottom: 0.51cm; direction: ltr; color: #000000; ...

  5. pc端常用导航

    应为经常要写网站,导航部分基本一样,没必要每次都写一遍,下次直接来复制: HTML: <nav> <div class="clearfix container"& ...

  6. zabbix2.2部署安装(安装环境Centos 6.* X64)

    1.在已有的LAMP或者LNMP的基础上安装zabbix,安装一些依赖包: 安装epel源:rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64 ...

  7. CSS样式表学习

    ---恢复内容开始--- 今天学习的主要内容是样式表和选择器. 1.样式表的分类 1.内联式样式表 特点:能实现精确控制,但是范围太小.页面显示的优先级高于其他样式表 2.内嵌式样式表 特点:必须在h ...

  8. Nginx集群之WCF分布式消息队列

    目录 1       大概思路... 1 2       Nginx集群之WCF分布式消息队列... 1 3       MSMQ消息队列... 2 4       编写WCF服务.客户端程序... ...

  9. H2Engine游戏服务器设计之属性管理器

    游戏服务器设计之属性管理器 游戏中角色拥有的属性值很多,运营多年的游戏,往往会有很多个成长线,每个属性都有可能被N个成长线模块增减数值.举例当角色戴上武器时候hp+100点,卸下武器时HP-100点, ...

  10. Spark算子篇 --Spark算子之aggregateByKey详解

    一.基本介绍 rdd.aggregateByKey(3, seqFunc, combFunc) 其中第一个函数是初始值 3代表每次分完组之后的每个组的初始值. seqFunc代表combine的聚合逻 ...