问题 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的更多相关文章

  1. Graph(2014辽宁ACM省赛)

    问题 F: Graph 时间限制: 1 Sec  内存限制: 128 MB 提交: 30  解决: 5 [cid=1073&pid=5&langmask=0" style=& ...

  2. 2014 ACM省赛总结

    今年ACM省赛已经过去一个星期左右了,2年的ACM训练是该做个总结了,因为前几日去參加蓝桥杯总决赛,所以没来的及写总结,如今在这小小总结一下吧-- 依晰记得去年省赛时候的样子,如今感觉那时像是个无知的 ...

  3. 第六届acm省赛总结(退役贴)

    前言: 这是我的退役贴,之前发到了空间里,突然想到也要在博客里发一篇,虽然我很弱,但是要离开了还是有些感触,写出来和大家分享一下,希望不要见笑.回来看看,这里也好久没有更新了,这一年确实有些懈怠,解题 ...

  4. [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. 这道题跟 ...

  5. [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛

    本文出自:http://blog.csdn.net/svitter 原题:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&am ...

  6. 1059. Prime Factors (25)

    时间限制 50 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given any positive integer N, y ...

  7. PAT 1059. Prime Factors (25) 质因子分解

    题目链接 http://www.patest.cn/contests/pat-a-practise/1059 Given any positive integer N, you are suppose ...

  8. PAT1059:Prime Factors

    1059. Prime Factors (25) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given ...

  9. A1059. Prime Factors

    Given any positive integer N, you are supposed to find all of its prime factors, and write them in t ...

随机推荐

  1. javaEE jdbc编程步骤

    1.载入数据库驱动(jar文件) //须要下载一个数据库的jar包,并导入对应的JDBC项目中,创建路径! Class.forName("com.mysql.jdbc.Driver" ...

  2. C#的c/s做出开灯关灯计算?

    static void light(Boolean[] lights,int n) {     if (n <= 1 || lights.Length<5) return;     for ...

  3. memcached 分布式聚类算法

    memcached 分布式集群,该决定必须书面开发商自己.和redis 由分布式server决定.上 memcached 有两个选项用于分布式.第一个是:模运算 另一种是:一致性hash 分布式算法. ...

  4. 【JUnit4.10来源分析】0导航

    JUnit靠GOF 中的一个Erich Gamma和 Kent Beck 单元测试框架编写一个开源,yqj2065分析JUnit的主要目的是源 中学习对设计模式的运用. JUnit也是一个学习Java ...

  5. Ubuntu下安装KDE及安装中文环境

    进入Ubuntu的默认安装的桌面后打开终端,输入 sudo apt-get install kubuntu-desktop 回车后输入密码接下来提示下载KDE需要多少空间,解压后需要多少空间,询问是否 ...

  6. IOS --- 日期时间格式 更改

    1.怎样怎样将一个字符串如" 20110826134106"装化为随意的日期时间格式.以下列举两种类型:    NSString* string =@"201108261 ...

  7. 使用vbs脚本添加域网络共享驱动器

    MapNetworkDrive Method Adds a shared network drive to your computer system. object.MapNetworkDrive(s ...

  8. RaspberryPI 连接rs232模块接线图

  9. 详细说明XML分解(两)—DOM4J

    第一部分关于博客XML三接口,同时也为学习DOM4J该分析工具做准备.一般解析器基本上都实现了DOM和SAX这两组接口,DOM4J自然也不例外..DOM4J仅仅是经常使用解析器的当中一种,只是既然是实 ...

  10. 阿里游戏大数据sesson2_RF&amp;GBRT(上)

    ----------一个小的游戏体验,对于不太熟悉Xlab RF和GBRT同学们都叫参考,不喜勿喷,大神绕道,米姆达. . .. .---------- 6月初的时候LR 做到4.9后一直上不去,看群 ...