3164 质因数分解
2016-05-25 16:34
267 查看
3164 质因数分解
时间限制: 1 s空间限制: 256000 KB
题目等级 : 黄金 Gold
题解
题目描述 Description
(多数据)给出t个数,求出它的质因子个数。
数据没坑,难度降低。
输入描述 Input Description
第一行 t
之后t行 数据
输出描述 Output Description
t行 分解后结果(质因子个数)
样例输入 Sample Input
2
11
6
样例输出 Sample Output
1
2
数据范围及提示 Data Size & Hint
(样例解释)11自己本身是一个质数,所以计入其中。
顺便提示:t<=100000。每个数小于long long unsigned 呵呵
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int n; long long x; void solve(long long a) { int p=0; for(long long i=2;i<=a;i++) if(a%i==0) while(a%i==0) { a=a/i; p++; } printf("%d\n",p); } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%lld",&x); solve(x); } return 0; }
相关文章推荐
- MYSQL系列-Mysql存储引擎选择
- 轮播图 jquery
- php的错误级别
- GStreamer基础教程08——pipeline的快捷访问
- Spark中组件Mllib的学习39之梯度提升树(GBT)用于分类*
- IP地址类
- phaser.js入门篇
- Android端 WebP图片压缩与传输的一点探索
- iOS开发之高级视图—— UITableView(四)自定义Cell
- 如何准备机器学习工程师的面试 ?
- idea14使用maven创建web工程
- 将mat格式中加标签的数据分为:训练集、验证集、测试集
- Power of Four and Power of Three - 4的次方和3的次方
- (已解决)Arduino mega2560 R3插在电脑上没有反应
- PHP面试题,附答案(1)
- 数据库-SQL语言的分类
- blkid命令 获取文件系统类型、UUID
- GPU 原理解密(一)画个三角形居然这么难
- 面向对象和面向过程
- js将本地时间与服务器时间同步