B. Duff in Love
2 seconds
256 megabytes
standard input
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.
The first and only line of input contains one integer,
n (1 ≤ n ≤ 1012).
Print the answer in one line.
10
10
12
6
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的素因子的乘积、记住与因子相关的都可以尝试着向素数方面靠、、
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdlib>
using namespace std; typedef long long int LL ; int main() {
LL n;
cin >> n;
LL res = 1;
for (LL i = 2; i*i<=n; i++) {
if (n %i ==0) {
res *= i;
while (n %i == 0)
n /= i;
}
}
cout << res*n<< endl; return 0;
}
B. Duff in Love的更多相关文章
- 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 ...
- 【转】Duff's Device
在看strcpy.memcpy等的实现发现用了内存对齐,每一个word拷贝一次的办法大大提高了实现效率,参加该blog(http://totoxian.iteye.com/blog/1220273). ...
- Codeoforces 558 B. Duff in Love
// B. Duff in Love time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Codeforces Round #326 (Div. 2)-Duff and Meat
题意: Duff每天要吃ai千克肉,这天肉的价格为pi(这天可以买好多好多肉),现在给你一个数值n为Duff吃肉的天数,求出用最少的钱满足Duff的条件. 思路: 只要判断相邻两天中,今天的总花费 = ...
- 【LCA】CodeForce #326 Div.2 E:Duff in the Army
C. Duff in the Army Recently Duff has been a soldier in the army. Malek is her commander. Their coun ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 达夫设备/达夫算法(Duff's Device)
主要是下面的代码: register n = (count + 7) / 8; /\* count > 0 assumed \*/ switch (count % 8) { case 0: ...
随机推荐
- ROS初探:(一)ROS架构
一.ROS架构 ROS架构上分为三个层级: 计算图级(Computation Graph level):体现进程与系统的关系,描述系统怎么运行. 文件系统级(Filesystem level):组织构 ...
- Windows上Python2与Python3共存
首先安装好python2与python3版本 因为安装顺序的不同,所以系统默认的版本也不同.如果先安装的是python,那么系统默认的就是python2 如果根据需求需要使用不同的版本,可以使用py命 ...
- [: 11: y: unexpected operator问题
<私房菜>上的shell脚本问题: 转载:[: 11: y: unexpected operator问题 脚本如下:% #!/bin/bash # Program: # This prog ...
- 从开源项目看python代码注释
最近看了不少代码,也写了不少代码,所以在看和写之间发现了很多的问题,真的是很多,至少从我的认识来看,有几个地方有很大的改进空间,这里不准备把所有的问题都列举出来,所以就先挑选一个比较明显得来和大家聊聊 ...
- textarea显示源代码
textarea显示源代码 近期做的项目中,有需要显示源码的效果 最开始使用了很多冗余的办法,使用<pre></pre>和<code></code>标签 ...
- Java学习笔记1(HelloWorld)
编写HelloWorld是一种仪式: 1.下载JDK,安装,注意路径中不要存在中文. 2.添加环境变量,加入bin目录 3.写一个文本,内容如下,后缀改成.java,注意文本的名称为HelloWorl ...
- 表单验证插件--formvalidation
表单验证是一个非常基础的功能,当你的表单项少的时候,可以自己写验证,但是当你的表单有很多的时候,就需要一些验证的插件.今天介绍一款很好用的表单验证插件,formvalidation.其前身叫做boot ...
- 【单调栈】最长不上升子序列变式,洛谷 P2757 导弹的召唤
题目背景 易琢然今天玩使命召唤,被敌军用空对地导弹轰炸,很不爽:众所周知,易琢然很不老实,他开了外挂: 外挂第一次可以打掉任意高度的导弹,之后每一次都不能打掉大于上一次高度的导弹: 但易琢然水平太差, ...
- Java集合系列[1]----ArrayList源码分析
本篇分析ArrayList的源码,在分析之前先跟大家谈一谈数组.数组可能是我们最早接触到的数据结构之一,它是在内存中划分出一块连续的地址空间用来进行元素的存储,由于它直接操作内存,所以数组的性能要比集 ...
- 如何学习java?Java基础知识点分享
面对未知的行业,人们的第一反应应该是:拒绝踏入.因为学习真的是一个痛苦的过程.想要真正了解一个行业,熟知一个行业,并熟练掌握某一技术,是真的需要时间和精力的.在学习Java基础知识期间,千锋小编疯狂为 ...