Codeforces Round #326 (Div. 2) 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 然你找到最大的一个数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",n);
return 0;
}
Codeforces Round #326 (Div. 2) B Duff in Love 简单数论 姿势涨的更多相关文章
- 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 ...
- Codeforces Round #326 (Div. 1) - C. Duff in the Army 树上倍增算法
题意:一个n个点的数, m个人住在其中的某些点上, 每个人的标号1-m, 询问u-v 路径上标号前a个人,并输出标号,a < 10. 作法, 利用倍增, ID[j][i] 表示i到i的第2^j个 ...
- Codeforces Round #326 Div.1 C.Duff in the Army 树上倍增
题意概述: 给出一棵N个结点的树,然后有M个居民分散在这棵树的结点上(允许某个结点没有居民).现在给出一些询问形如u,v,a,定义k=min(x,a),其中x表示的是u->v路径上的居民数量.将 ...
- 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 ...
- Codeforces Round #326 (Div. 2)-Duff and Meat
题意: Duff每天要吃ai千克肉,这天肉的价格为pi(这天可以买好多好多肉),现在给你一个数值n为Duff吃肉的天数,求出用最少的钱满足Duff的条件. 思路: 只要判断相邻两天中,今天的总花费 = ...
- 「日常训练」Duff in the Army (Codeforces Round #326 Div.2 E)
题意(CodeForces 588E) 给定一棵\(n\)个点的树,给定\(m\)个人(\(m\le n\))在哪个点上的信息,每个点可以有任意个人:然后给\(q\)个询问,每次问\(u\)到\(v\ ...
随机推荐
- sqlserver错误126解决方法
是不是很尴尬! 华丽的分割线下便是解决方法: 1.打开sqlserver配置管理器. 2.选择sqlserver网络配置,并禁用VIA协议确定保存. 3.在服务里面启动[SQL Server (SQL ...
- 使用js跳转手机站url的若干注意点
引子: 去年年底公司开发手机站平台,经历了前期的用户群.市场调查,产品需求分析,产品原型设计,ui前端到程序开发上线测试等等工作,终于上线...此处略去本人作为前端开发的心情. 应该说,我们的手机站平 ...
- FPGA学习-VGA接口
一般FPGA开发板的VGA会向用户暴露两共五个种接口,第一种是时序信号,用于同步传输和显示:第二种是色彩信号,用于随着时序把色彩显示到显示器上 时序接口 行同步信号-用于指示一行内像素的显示 场同步信 ...
- Period :KMP
I - Period Problem Description For each prefix of a given string S with N characters (each character ...
- 吴恩达深度学习 反向传播(Back Propagation)公式推导技巧
由于之前看的深度学习的知识都比较零散,补一下吴老师的课程希望能对这块有一个比较完整的认识.课程分为5个部分(粗体部分为已经看过的): 神经网络和深度学习 改善深层神经网络:超参数调试.正则化以及优化 ...
- SPOJ 8073 The area of the union of circles(计算几何の圆并)(CIRU)
Description You are given N circles and expected to calculate the area of the union of the circles ! ...
- Memory及其controller芯片整体测试方案(下篇)
{ 第三部分 } DDR总线的设计.调试和验证 在计算机架构中,DDR作为程序运算的动态存储器,面对如高性能计算.图形计算.移动计算.工业应用等领域的要求,发展出DDR4,以及用于图形计算的G ...
- 自测之Lesson8:进程操作
题目:请解释wait是如何同步父子进程的. 程序代码: #include <stdio.h> #include <unistd.h> #include <sys/type ...
- Prime Matrix(暴力出奇迹)
Description You've got an n × m matrix. The matrix consists of integers. In one move, you can apply ...
- .net平台借助第三方推送服务在推送Android,IOS消息(极光推送_V3版本)最新
最近刚从极光推送官网上看到V2版本要停用,不得不有重新写V3版本的.这里用到了 HTTP Basic Authentication http://www.cnblogs.com/pingming/p/ ...