数论题,本质是求出n的最大质因子

 #include<time.h>
#include <cstdio>
#include <iostream>
#include<algorithm>
#include<math.h>
#include <string.h>
#include<vector>
#include<queue>
using namespace std; int main()
{
int n,t;
while(scanf("%d",&n)!=EOF)
{
if(n == ) //注意1不是素数,找不到最大质因子
{
printf("0\n");
continue;
} else
{
t=n;
int maxx=;
for(int i=;i<=int(sqrt(n));i++)
while(t%i==)
{
t/=i;
maxx=i;
}
maxx=max(t,maxx);
printf("%d\n",n/maxx);
}
}
return ;
}

hdu 5108 Alexandra and Prime Numbers的更多相关文章

  1. hdu 5108 Alexandra and Prime Numbers(水题 / 数论)

    题意: 给一个正整数N,找最小的M,使得N可以整除M,且N/M是质数. 数据范围: There are multiple test cases (no more than 1,000). Each c ...

  2. Alexandra and Prime Numbers(思维)

    Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  3. HDOJ(HDU) 2138 How many prime numbers(素数-快速筛选没用上、)

    Problem Description Give you a lot of positive integers, just to find out how many prime numbers the ...

  4. HDU 2138 How many prime numbers(Miller_Rabin法判断素数 【*模板】 用到了快速幂算法 )

    How many prime numbers Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  5. BestCoder19 1001.Alexandra and Prime Numbers(hdu 5108) 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5108 题目意思:给出一个数正整数 N,N <= 1e9,现在需要找出一个最少的正整数 M,使得 ...

  6. HDU 2138 How many prime numbers

    米勒罗宾素数测试: /* if n < 1,373,653, it is enough to test a = 2 and 3. if n < 9,080,191, it is enoug ...

  7. HDU 2138 How many prime numbers (判素数,米勒拉宾算法)

    题意:给定一个数,判断是不是素数. 析:由于数太多,并且太大了,所以以前的方法都不适合,要用米勒拉宾算法. 代码如下: #include <iostream> #include <c ...

  8. hdu 5108(数论-整数分解)

    Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  9. How many prime numbers(素数)

    Problem Description   Give you a lot of positive integers, just to find out how many prime numbers t ...

随机推荐

  1. javaweb 解决将ajax返回的内容用document.write写入,FireFox一直加载的问题

    在document.write方法后加上document.close就解决了, 想知道原理的小伙伴可以继续看 浏览器在解析html时会打开一个流,这是用document.write中写入,是加入当解析 ...

  2. UITabBarController的使用和坑

    本人apem 说到UITabBarController, 最首要的坑就是tabbar的图片不显示的问题 1. tabbar上的图片一定要2套以上, 例如一个uitabbaritem的image是 se ...

  3. 《C和指针(Pointer on c)》 学习笔记(转自:http://dsqiu.iteye.com/blog/1687944)

    首先本文是对参考中三个连接的博客进行的整理,非常感谢三位博主的努力,每次都感叹网友的力量实在太强大了…… 第一章 快速上手 1.  在C语言中用/*和*/来注释掉这段代码,这个实际上并不是十分的安全, ...

  4. opencv删除二值图中较小的噪点色块

    CvSeq* contour = NULL; double minarea = 100.0; double tmparea = 0.0; CFileDialog dlg(true); if (dlg. ...

  5. UIView的一些基本方法 init、loadView、viewDidLoad、viewDidUnload、dealloc

    init方法 在init方法中实例化必要的对象(遵从LazyLoad思想) ‍init方法中初始化ViewController本身 loadView方法 当view需要被展示而它却是nil时,view ...

  6. 百度云+ KeePass 网络同步你的密码

     百度云+ KeePass 网络同步你的密码   百度云一个目前不限流量不限格式能直链的网盘,速度在我这里很快,难得了!KeePass(小众介绍过 KeePass.) 是一个免费开源的密码管理类软件, ...

  7. ubuntu 16.04 apt-get error: in the drive /media/cdrom and press

    If you have an internet connection, you can safely comment out the line starting with deb cdrom: ... ...

  8. 第三方登录(QQ登录)开发流程详解

    原文:http://www.cnblogs.com/it-cen/p/4338202.html 近排由于工作的繁忙,已经一个星期没写博文做分享了,接下来我对网站接入第三方登录----QQ登录的实现逻辑 ...

  9. c++转义字符、指针

    上篇博客的答案: 1: // DataTypeDemo.cpp : 定义控制台应用程序的入口点. 2: // 3:  4: #include "stdafx.h" 5: #incl ...

  10. liunux mysql MySQL表名不区分大小写的设置方法

    原来Linux下的MySQL默认是区分表名大小写的,通过如下设置,可以让MySQL不区分表名大小写:1.用root登录,修改 /etc/my.cnf:2.在[mysqld]节点下,加入一行: lowe ...