题目:

输入一个数N,计算N的阶乘的质因数的个数,按质数从小到大排列输出各个质数的个数。

Input:

测试用例的个数T(0<T<=100)

要求的数N(2<=N<=100)

输出:

N!的质因数的个数序列

如:

3

5

10

100

输出:

Case #1

3 1 1

Case #2

8 4 2 1

Case #3

97 48 24 16 9 7 5 5 4 3 3 2 2 2 2 1 1 1 1 1 1 1 1 1 1

代码如下:

#include<iostream>
using namespace std;
//#define DEBUG
int Prim[25] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97 };
int Table[102] = { 0, };
void Init()
{
for (int i = 0; i < 25; i++)
Table[Prim[i]] = 1;
}
int Get(int n, int num)
{
if (n == 0) return 0;
else return Get(n / num, num) + n / num;
}
int main()
{
Init();
#ifdef DEBUG
freopen("Input.txt", "r", stdin);
setbuf(stdout, NULL);
#endif
int tc, T;
int N;
cin >> T;
for (int tc = 1; tc <= T; tc++)
{
cin >> N;
cout << "Case #" << tc << endl;
for (int j = 2; j <= N;j++)
{
if (Table[j] == 1)
{
int count = Get(N, j);
cout << count <<' ';
}
}
}
return 0;
}

Factors and Factorials相关推荐

  1. UVA160 Factors and Factorials【筛选法】

    The factorial of a number N (written N!) is defined as the product of all the integers from 1 to N. ...

  2. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  3. π-Algorithmist分类题目(1)

    原题网站:Algorithmist,http://www.algorithmist.com/index.php/Main_Page π-Algorithmist分类题目(1) Sorting UVAL ...

  4. UVa Online Judge 工具網站

    UVa Online Judge 工具網站 转自http://www.csie.ntnu.edu.tw/~u91029/uva.html Lucky貓的ACM園地,Lucky貓的 ACM 中譯題目 M ...

  5. HOJ题目分类//放这儿没事刷刷学算法!嘻嘻!

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  6. 1096 Consecutive Factors

    1. 对于题目描述中 list the smallest sequence of the consecutive factors 正确理解是:如果有多组连续因子,输出开头因子最小的那个序列(一开始理解 ...

  7. Error in Math.factor() : ‘sqrt’ not meaningful for factors

    Error in Math.factor() : 'sqrt' not meaningful for factors 目录 Error in Math.factor() : 'sqrt' not me ...

  8. Error in contrasts can be applied only to factors with 2 or more levels

    Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]): contrasts can be applied only ...

  9. Error in Math.factor(x) : ‘abs’ not meaningful for factors

    Error in Math.factor(x) : 'abs' not meaningful for factors Error in Math.factor(x_fac): 'abs' not me ...

最新文章

  1. Intellij IDEA 没办法创建java文件
  2. 第2关:实现一个链接存储的栈
  3. 网站优化工作关键——稳定排名!
  4. 对计算机应用的认识100,计算机应用基础
  5. window中osmnx包的详细安装过程
  6. 在CentOS Linux上安装oracle11g之二 安装oracle11g
  7. 项目实战中如何使用抽象类和接口
  8. 给超链接(a标签)加onclick事件
  9. numpy 转置_Numpy基础:数组转置和轴对换
  10. 网页版进销存源码ERP多仓库管理系统源码
  11. 七.激光SLAM框架学习之A-LOAM框架---速腾Robosense-16线雷达室内建图
  12. 自己在项目中写的一个Jquery插件和Jquery tab 功能
  13. 串口类QextSerialPort
  14. Golang 实现本地身份证归属地查询
  15. STM32F1--FreeRTOS系统移植运行报错:L6218E:Undefined symbol xTaskGetSchedulerState (referred from delay.o)
  16. Python pyglet 自制3D引擎入门(一) -- 绘制几何体、创建3D场景
  17. uniapp用canvas实现分享海报
  18. jQuery 学习-样式篇(五):jQuery 设置元素的 html 结构或 text 内容
  19. GeneXus中如何使用聊天机器人
  20. 刚子:走马观花奋达创“芯”发布会

热门文章

  1. python npv 计算公式_Python numpy 中常用的数据运算
  2. 易语言EIP永久注入
  3. SpringCloud知识点总结
  4. HASH和HMAC(5):SHA-384、SHA-512、SHA-512/224和SHA-512/256算法原理
  5. springboot+jsp人事工资管理系统 java ssm maven
  6. 幼儿抽象逻辑思维举例_幼教科目二丨幼儿认知的发展(思维)
  7. python使用代理爬虫_python使用代理爬虫导致无法访问网页
  8. rk3288 android7.1 蓝牙传送文件失败
  9. JMeter 调试取样器(Debug Sampler)简介
  10. 移动端网页特效以及常用开发框架