uva-10392-因数分解
- #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-因数分解的更多相关文章
- UVA 10392 (13.07.28)
Problem F: Factoring Large Numbers One of the central ideas behind much cryptography is that factori ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
- UVA计数方法练习[3]
UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...
- 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 ...
- UVA - 1625 Color Length[序列DP 代价计算技巧]
UVA - 1625 Color Length 白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束 和模拟赛那道环形DP很想,计算这 ...
- UVA - 10375 Choose and divide[唯一分解定理]
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- 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 ...
随机推荐
- 在python中的使用
操作步骤: 1. 连接数据库,生成数据库连接对象 conn = pymongo.MongoClient('localhost',27017) 2. 选择要操作的数据库,生成数据库对象 (__setit ...
- ADC复用重映射
- 什么是PHP无限级分类
注:兄弟连PHP项目视频18讲有详细讲解.PHP和mysql(或是各种数据库)有较深的依奈关系,比如这里就是通过数据库的设 计,id,pid(parent id),path(所有父id构成的路径,如W ...
- 【java规则引擎】《Drools7.0.0.Final规则引擎教程》第4章 4.2 auto-focus
转载至:https://blog.csdn.net/wo541075754/article/details/75349556 auto-focus 在agenda-group章节,我们知道想要让Age ...
- mysql 行号 获取指定行数据
mysql 行号的实现 Select id,(@rowNum:=@rowNum+1) as rowNo From first,(Select (@rowNum :=0) ) bOrder by fir ...
- Swift 学习笔记十五:扩展
扩展就是向一个已有的类.结构体或枚举类型加入新功能(functionality).扩展和 Objective-C 中的分类(categories)相似.(只是与Objective-C不同的是,Swif ...
- JUC原子类之 原子操作数据类型
根据修改的数据类型,可以将JUC包中的原子操作类可以分为4类. 基本类型: AtomicInteger, AtomicLong, AtomicBoolean ; 数组类型: AtomicInteger ...
- PHP查找中文字符的解决方案
在PHP中查找中文字符,有两种方案.1.中文字符是gbk(gb2312)有两种解决方法第一种:将PHP保存为ASCII编码,然后使用strpos查找,如:strpos($curl_res, ‘哈哈’) ...
- LOJ 2542 「PKUWC2018」随机游走 ——树上高斯消元(期望DP)+最值反演+fmt
题目:https://loj.ac/problem/2542 可以最值反演.注意 min 不是独立地算从根走到每个点的最小值,在点集里取 min ,而是整体来看,“从根开始走到点集中的任意一个点就停下 ...
- [转]StarWind模拟iSCSI设备
StarWind模拟iSCSI设备 url: http://jimshu.blog.51cto.com/3171847/590412/ 标签:职场 iSCSI 休闲 StarWind 原创作品,允许 ...