1. #include<stdio.h>
  2. #include<iostream>
  3. #include<queue>
  4. #include<memory.h>
  5. #include <math.h>
  6. #include<time.h>
  7. #include <stdlib.h>
  8. using namespace std;
  9.  
  10. const int MAX = * ;
  11. const int MAXL = * ;
  12. /**
  13. * 欧拉素数筛选法
  14. */
  15. int prime[MAX];
  16. int np = ;
  17. void primes()
  18. {
  19. memset(prime, -, sizeof(prime));
  20. for(int i = ; i <= MAXL; i++)
  21. {
  22. if(prime[i] == -)
  23. prime[np++] = i;
  24. for(int j = ; j < np && prime[j] * i <= MAXL; j++)
  25. {
  26. if(prime[j] * i >= MAXL)
  27. {
  28. break;
  29. }
  30. prime[prime[j] * i] = ;
  31. if(i % prime[j] == )
  32. break;
  33. }
  34. }
  35. }
  36. int main()
  37. {
  38. freopen("d:\\1.txt", "r", stdin);
  39. primes();
  40. long long l;
  41. bool first = true;
  42. while (cin >> l)
  43. {
  44. if(l == -)
  45. return ;
  46. for(int i = ; i < np && prime[i] <= l; i++)
  47. {
  48. while (l % prime[i] == )
  49. {
  50. l = l / prime[i];
  51. printf(" %d\n", prime[i]);
  52. }
  53. }
  54. if(l != )
  55. {
  56. printf(" %lld\n", l);
  57. }
  58. cout << endl;
  59. }
  60. return ;
  61. }

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. 在python中的使用

    操作步骤: 1. 连接数据库,生成数据库连接对象 conn = pymongo.MongoClient('localhost',27017) 2. 选择要操作的数据库,生成数据库对象 (__setit ...

  2. ADC复用重映射

  3. 什么是PHP无限级分类

    注:兄弟连PHP项目视频18讲有详细讲解.PHP和mysql(或是各种数据库)有较深的依奈关系,比如这里就是通过数据库的设 计,id,pid(parent id),path(所有父id构成的路径,如W ...

  4. 【java规则引擎】《Drools7.0.0.Final规则引擎教程》第4章 4.2 auto-focus

    转载至:https://blog.csdn.net/wo541075754/article/details/75349556 auto-focus 在agenda-group章节,我们知道想要让Age ...

  5. mysql 行号 获取指定行数据

    mysql 行号的实现 Select id,(@rowNum:=@rowNum+1) as rowNo From first,(Select (@rowNum :=0) ) bOrder by fir ...

  6. Swift 学习笔记十五:扩展

    扩展就是向一个已有的类.结构体或枚举类型加入新功能(functionality).扩展和 Objective-C 中的分类(categories)相似.(只是与Objective-C不同的是,Swif ...

  7. JUC原子类之 原子操作数据类型

    根据修改的数据类型,可以将JUC包中的原子操作类可以分为4类. 基本类型: AtomicInteger, AtomicLong, AtomicBoolean ; 数组类型: AtomicInteger ...

  8. PHP查找中文字符的解决方案

    在PHP中查找中文字符,有两种方案.1.中文字符是gbk(gb2312)有两种解决方法第一种:将PHP保存为ASCII编码,然后使用strpos查找,如:strpos($curl_res, ‘哈哈’) ...

  9. LOJ 2542 「PKUWC2018」随机游走 ——树上高斯消元(期望DP)+最值反演+fmt

    题目:https://loj.ac/problem/2542 可以最值反演.注意 min 不是独立地算从根走到每个点的最小值,在点集里取 min ,而是整体来看,“从根开始走到点集中的任意一个点就停下 ...

  10. [转]StarWind模拟iSCSI设备

    StarWind模拟iSCSI设备 url: http://jimshu.blog.51cto.com/3171847/590412/  标签:职场 iSCSI 休闲 StarWind 原创作品,允许 ...