B - Duff in Love(数论)
来源:互联网 发布:电脑设计软件培训 编辑:程序博客网 时间:2024/05/29 08:34
题目地址
题目大意:在数n的因子中求满足其不是任意一个数的平方的倍数的最大因子
解题思路:对于一个数n(1e12),其一半的因子一定<=sqrt(n),且根据这部分因子可求出另一部分因子,则对于数n的因子,若要使其不是任一个数的平方的倍数,则将其每个因子的都除掉,对于每一个因子留一个相乘起来,即满足了该数不会是某一数的平方的倍数,另因为是乘了所有的因子,所以一定是最大的~
#include <bits/stdc++.h>using namespace std;const int maxn = 1e6+100;int main(){ __int64 n; while(scanf("%I64d",&n) != EOF) { __int64 tmp = sqrt(n); __int64 ans = 1; for(__int64 i = 2; i <= tmp; i++) { if(n%i==0) { ans *= i; while(n%i==0) n/=i; } } if(n!=1) ans *= n; printf("%I64d\n",ans); } return 0;}
0 0
- B - Duff in Love(数论)
- Code Forces 588 B. Duff in Love(数论)
- B. Duff in Love
- B. Duff in Love
- codeforces - 326B - Duff in Love(练习)
- codeforces#326-B-Duff in Love-暴力
- coderforce 588B Duff in Love
- CF 588B Duff in Love
- codeforces 588 B Duff in Love
- Codeforces 588B Duff in Love 【数学】
- CodeForces 588B Duff in Love
- Duff in Love
- Codeforces Round #326 (Div. 2)B. Duff in Love
- Codeforces Round #326 (Div. 2) 588 B. Duff in Love
- Codeforces Round #326 (Div. 2) B. Duff in Love
- Codeforces Round #326 (Div. 2)B. Duff in Love
- Codeforces 588B Duff in Love【暴力】水题
- Duff in Love(素因子的应用)
- jQuery 获取屏幕高度、宽度
- update数组实现
- Qt学习之路_13(简易俄罗斯方块)
- android极光推送初步了解
- 在linux系统中如何使用命令行获取本机的公网IP
- B - Duff in Love(数论)
- URI和URL的区别
- Sql Server远程连接数据库(相当于Oracle的dblink方式)
- Tomcat 7 中的 JDBC Realm 配置
- [svn] linux命令——svn分支创建、合并
- hdoj 2509 Be the Winner 【博弈】
- C语言面向对象之继承、多态、可变参数、函数指针
- Liunx sed
- CSS背景靠右对齐,并且背景图片右边刘10px