#include<stdio.h>
#include<iostream>
#include<queue>
#include<memory.h>
#include <math.h>
#include<time.h>
#include <stdlib.h>
using namespace std; const int MAX = * ;
const int MAXL = * ;
/**
* 欧拉素数筛选法
*/
int prime[MAX];
int np = ;
void primes()
{
memset(prime, -, sizeof(prime));
for(int i = ; i <= MAXL; i++)
{
if(prime[i] == -)
prime[np++] = i;
for(int j = ; j < np && prime[j] * i <= MAXL; j++)
{
if(prime[j] * i >= MAXL)
{
break;
}
prime[prime[j] * i] = ;
if(i % prime[j] == )
break;
}
}
}
int main()
{
freopen("d:\\1.txt", "r", stdin);
primes();
long long l;
bool first = true;
while (cin >> l)
{
if(l == -)
return ;
for(int i = ; i < np && prime[i] <= l; i++)
{
while (l % prime[i] == )
{
l = l / prime[i];
printf(" %d\n", prime[i]);
}
}
if(l != )
{
printf(" %lld\n", l);
}
cout << endl;
}
return ;
}

uva-10392-因数分解的更多相关文章

  1. UVA 10392 (13.07.28)

    Problem F: Factoring Large Numbers One of the central ideas behind much cryptography is that factori ...

  2. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  3. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  4. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  5. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

  6. UVA计数方法练习[3]

    UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...

  7. UVA数学入门训练Round1[6]

    UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...

  8. UVA - 1625 Color Length[序列DP 代价计算技巧]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

  9. UVA - 10375 Choose and divide[唯一分解定理]

    UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  10. UVA - 11584 Partitioning by Palindromes[序列DP]

    UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...

随机推荐

  1. Unity3D游戏-愤怒的小鸟游戏源码和教程(二)

    Unity愤怒的小鸟游戏教程(二) 本文提供全流程,中文翻译.Chinar坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 -- 高分辨率用户请根据需求调整网页缩放比例) AngryEva游戏效果 ...

  2. with() {} 的用法

    var use = "other"; var katana = { isSharp: true, use: function(){ this.isSharp = !!this.is ...

  3. POJ 2585:Window Pains(拓扑排序)

    Window Pains Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2524   Accepted: 1284 Desc ...

  4. Centos(linux)下的Python

    Centos(linux)下安装python3(python2和python3共存) yum -y install lrzsz 首先安装lrzsz工具,lrzsz是一款在linux里可代替ftp上传和 ...

  5. 2018-2019-2 《网络对抗技术》Kali安装 Week1 20165212

    2018-2019-2 <网络对抗技术>Kali安装 Week1 20165212 1.完成安装linux kali和vm tools 装的第三遍成功安装.前面两次镜像文件不行,没驱动(网 ...

  6. smarty学习——高级知识

    1.Objects 对象 smarty允许通过模板访问PHP对象.有两种方式来访问它们.一种是注册对象到模板,然后通过类似于用户自定义函数的形式来访问它. 另一种方法给模板分配对象,然后通过访问其它赋 ...

  7. Nginx+redis部署tomcat集群

    一.部署环境: 两个tomcat实例部署在Ubuntu 14上,IP地址分别为192.168.1.110和192.168.1.111,Nginx和redis部署在windows7上,IP地址为192. ...

  8. mysql 聚簇索引、非聚簇索引的区别

    索引分为聚簇索引和非聚簇索引. 以一本英文课本为例,要找第8课,直接翻书,若先翻到第5课,则往后翻,再翻到第10课,则又往前翻.这本书本身就是一个索引,即"聚簇索引". 如果要找& ...

  9. JSP中的EL (Express Language表达式语言)

    EL语言的目的: 用于无java代码的JSP页面 创建el1.jsp,el2.jsp el1.jsp <%@ page language="java" contentType ...

  10. Django的 admin管理工具

    admin组件使用 Django 提供了基于 web 的管理工具. Django 自动管理工具是 django.contrib 的一部分.你可以在项目的 settings.py 中的 INSTALLE ...