问题 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. shell统计

    for i in `ls -r *_*.csv`;do cat $i|echo $i": "`wc -l`;done>tongji.txt

  2. Node.js v0.10.31API手冊-控制台

    Node.js v0.10.31API手冊-文件夹 控制台 Object 用于向 stdout 和 stderr 打印字符.类似于大部分 Web 浏览器提供的 console 对象函数,在这里则是输出 ...

  3. 工作经常使用的SQL整理,实战篇(一)

    原文:工作经常使用的SQL整理,实战篇(一) 工作经常使用的SQL整理,实战篇,地址一览: 工作经常使用的SQL整理,实战篇(一) 工作经常使用的SQL整理,实战篇(二) 工作经常使用的SQL整理,实 ...

  4. UE4编码规范

    翻译原文为Unreal 的官方!自己看着总结了一下,不一定每条都能对上.不足之处,请多多不吝赐教! 原文地址:  unreal CodingStandard UE4编码规范 在Epic,有简单几条代码 ...

  5. jquery 如何动态绑定传递到后台上传组件参数

    $("#upload_photo").uploadify({ 'auto' : false, 'method' : "post", 'height' : 20, ...

  6. 动态Lambda进阶一

    直接上代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using S ...

  7. 3、Spring4之Bean 配置的细节

    1). 若字面值中包括特殊字符,则能够使用 value 节点的 <![CDATA[]]> 把字面值包裹起来.      <constructor-arg>           ...

  8. PDO基本操作Mysql

    来源:PHP开发学习门户 地址:http://www.phpthinking.com/archives/805 PHP中的PDO扩展为PHP訪问数据库定义了一个轻量级的.一致性的接口.它提供了一个数据 ...

  9. 了解HTML5和“她”的 API (三)

    Web Workers(后台线程) JavaScript是单线程的,较长的javascript运算会阻塞UI线程. web worker 是运行在后台的 JavaScript,不会影响页面的性能. 在 ...

  10. Linux下 高性能、易用、免费的ASP.NET服务器

    Linux下 高性能.易用.免费的ASP.NET服务器 http://www.jexus.org/#