uva-10392-因数分解
2024-08-26 08:00:52
#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 ;
}
最新文章
- ubuntu 启动MySql和安装python的MySQLdb模块
- iOS 启动图那些坑
- 工作中遇到的小问题: 做弹幕从数据库取出东西均匀插入marquee中,
- jspace2d——A free 2d multiplayer space shooter
- 大话string
- 它们的定义actionbar 并删除留空
- diy51单片机最小系统------从零件到51整体测试成功小白篇
- 使用XIB实现嵌套自定义视图
- redis 系列12 哈希对象
- Python3学习之路~9.1 paramiko模块:实现ssh执行命令以及传输文件
- 全网最详细的基于Ubuntu14.04/16.04 + Anaconda2 / Anaconda3 + Python2.7/3.4/3.5/3.6安装Tensorflow详细步骤(图文)(博主推荐)
- Confluence 6 恢复一个空间
- “一切都是消息”--iMSF(即时消息服务框架)入门简介
- Java编译报错:意外的类型
- android studio 3.0 安装配置
- Ansible之ansible-playbook roles
- Python3.x:os.chdir(改变当前路径方法)介绍
- python 2.7中安装mysql
- sql数据库表容量
- BZOJ:2460[BeiJing2011]元素 (异或基+贪心)