2014辽宁ACM省赛 Prime Factors
问题 L: Prime Factors
时间限制: 1 Sec 内存限制: 128 MB
提交: 36 解决: 28
[提交][状态][论坛]
题目描写叙述
I'll give you a number , please tell me how many different prime factors in this number.
输入
There is multiple test cases , in each test case there is only one line contains a number N(2<=N<=100000). Process to the end of file.
输出
For each test case , output one line contains one number , indicating different prime factor in the number N.
例子输入
12 5 30
例子输出
2 1 3
提示
12 = 2 * 2 * 3
5 = 5
30 = 2 * 3 * 5
水题一道,打表,枚举质因子就完了。
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int MAX=100000;
vector<int> f;
void init()
{
int k=0;
for(int i=2;i<=MAX;i++)
{
bool flag=true;
for(int j=2;j<=sqrt(i);j++)
{
if(i%j==0)
{
flag=false;
break;
}
}
if(flag)
f.push_back(i);
}
}
int main()
{
init();
int n;
while(cin>>n)
{
int cnt=0;
for(int i=0;i<f.size();i++)
{
if(n%f[i]==0)
{
cnt++;
n/=f[i];
while(n%f[i]==0)
{
n/=f[i];
}
}
}
cout<<cnt<<endl;
}
return 0;
}
2014辽宁ACM省赛 Prime Factors的更多相关文章
- Graph(2014辽宁ACM省赛)
问题 F: Graph 时间限制: 1 Sec 内存限制: 128 MB 提交: 30 解决: 5 [cid=1073&pid=5&langmask=0" style=& ...
- 2014 ACM省赛总结
今年ACM省赛已经过去一个星期左右了,2年的ACM训练是该做个总结了,因为前几日去參加蓝桥杯总决赛,所以没来的及写总结,如今在这小小总结一下吧-- 依晰记得去年省赛时候的样子,如今感觉那时像是个无知的 ...
- 第六届acm省赛总结(退役贴)
前言: 这是我的退役贴,之前发到了空间里,突然想到也要在博客里发一篇,虽然我很弱,但是要离开了还是有些感触,写出来和大家分享一下,希望不要见笑.回来看看,这里也好久没有更新了,这一年确实有些懈怠,解题 ...
- [CareerCup] 7.7 The Number with Only Prime Factors 只有质数因子的数字
7.7 Design an algorithm to find the kth number such that the only prime factors are 3,5, and 7. 这道题跟 ...
- [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
本文出自:http://blog.csdn.net/svitter 原题:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&am ...
- 1059. Prime Factors (25)
时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given any positive integer N, y ...
- PAT 1059. Prime Factors (25) 质因子分解
题目链接 http://www.patest.cn/contests/pat-a-practise/1059 Given any positive integer N, you are suppose ...
- PAT1059:Prime Factors
1059. Prime Factors (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given ...
- A1059. Prime Factors
Given any positive integer N, you are supposed to find all of its prime factors, and write them in t ...
随机推荐
- As long as Binbin loves Sangsang
题目连接 题意: 给定一个无向图,每一个边有两个属性.长度和一个字母'L','O','V'.'E'中的一个.从1点開始到达n点,每次必须依照L -> O -> V -> E -> ...
- mysql xtrabackup增量备份
mysql 增量备份策略 周一全备,其他增量备份,根据业务需要,设定保留日期,如保留一月. 增量备份步骤; 1 创建全备 2 根据全备目录,创建增量备份 3 第二次增量备份根据第一次增量备份目录,依次 ...
- Source not found for StandardEngine(ContainerBase).initInternal() line: 1078
总是这样 在复制完一个项目,并重新起了个名字后. 再打开网页就怎么也打开不了. 第一反应是tomcat出问题了. 于是有了这样的问题: Source not found for StandardE ...
- Phpcms所有系统变量列表 Phpcms V9 文件目录结构
Phpcms所有系统变量列表 用户变量: view plaincopy to clipboardprint? $_userid 用户id $_username 用户名 $_areaid ...
- 树形dp专辑
hdu 2196 http://acm.hdu.edu.cn/showproblem.php?pid=2196 input 5//5个结点 1 1//表示结点2到结点1有一条权值为1的边 2 1//表 ...
- NLB+Application Request Route 网路负载均衡
NLB网路负载均衡管理器详解 序言 在上一篇配置iis负载均衡中我们使用啦微软的ARR,我在那篇文章也中提到了网站的高可用性,但是ARR只能做请求入口的消息分发服务,这样如果我们的消息分发服务器给 ...
- state pattern
6 状态模式总结 状态模式将一个对象在不同状态下的不同行为封装在一个个状态类中,通过设置不同的状态对象可以让环境对象拥有不同的行为,而状态转换的细节对于客户端而言是透明的,方便了客户端的使用.在实际开 ...
- win8/win10/win2012r2 存储池 冗余分析
StorageSpace:a. Simple,相当于RAID0,无冗余,不考虑b. Two-way Mirror,双重镜像,至少2块盘,性能单盘,可以坏一块盘c. Three-way Mirror,三 ...
- 非常不错 Hadoop 的HDFS (Hadoop集群(第8期)_HDFS初探之旅)
1.HDFS简介 HDFS(Hadoop Distributed File System)是Hadoop项目的核心子项目,是分布式计算中数据存储管理的基础,是基于流数据模式访问和处理超大文件的需求而开 ...
- ASF(传感器)
版权声明:曾经的Blog文章合并.原创作品,谢绝转载.否则将追究法律责任. SensorManager类:用于创建sensor service的实例.该类提供了非常多 用于訪问和枚举传感器,注冊和注销 ...