hdu Largest prime factor
类似于素数打表。
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 1000100
using namespace std; int f[maxn]; void inti()
{
int num=;
for(int i=; i<maxn; i++)
{
if(f[i]==)
{
num++;
for(int j=i; j<maxn; j+=i)
{
f[j]=num;
}
}
}
} int main()
{
int n;
inti();
while(scanf("%d",&n)!=EOF)
{
printf("%d\n",f[n]);
}
return ;
}
hdu Largest prime factor的更多相关文章
- 水题 第三站 HDU Largest prime factor
先写一遍思路,跟素数表很类似吧. 1)从小到大遍历数据范围内的所有数.把包含质因子的数的位置都设成跟质因子的位置相同. 2)同一个数的位置可能被多次复写.但是由于是从小到大遍历,这就保证了最后一次写入 ...
- HDOJ(HDU) 2136 Largest prime factor(素数筛选)
Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...
- 【沙茶了+筛选保存最大质因数】【HDU2136】Largest prime factor
Largest prime factor Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 2136 Largest prime factor(打表)
Problem Description Everybody knows any number can be combined by the prime number.Now, your task is ...
- [暑假集训--数论]hdu2136 Largest prime factor
Everybody knows any number can be combined by the prime number. Now, your task is telling me what po ...
- The largest prime factor(最大质因数)
1. 问题: The prime factors of 13195 are 5, 7, 13 and 29.What is the largest prime factor of the number ...
- (Problem 3)Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...
- Largest prime factor
problem 3:Largest prime factor 题意:求600851475143的最大的质因数 代码如下: #ifndef PRO3_H_INCLUDED #define PRO3_H_ ...
- Problem 3: Largest prime factor
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 60085 ...
随机推荐
- activity5 流程 入门
http://blog.csdn.net/yangyi22/article/details/9225849 谢谢原文作者提供!
- rsyslog 只读取变化的日志
<pre name="code" class="html">input(type="imfile" File="/us ...
- 【HDOJ】3184 All Can Do
简单数学题. #include <cstdio> #include <cstring> #include <cstdlib> int main() { int t; ...
- Qt入门(4)——Qt常见控件
Qt提供了大量的内建控件及通用对话框可满足程序员的绝大部分要求.我们将对这些控件和对话框作一个大概的介绍. 1. QLabel 定义 QLabel* m_labelOrdered = newQLabe ...
- Android中使用shape制作一个旋转的progressbar
public class ZNtestResActivity extends Activity { @Override public void onCreate(Bundle savedInstanc ...
- HDU_1016——素环问题DFS
Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ... ...
- [C++]memcpy 小记
#include <stdio.h> #include <stdlib.h> #include <string.h> int main () { char a = ...
- [Angular 2] Using Promise to Http
You can also use Promise for http: So for the service, you need to call toPromise() method: getVehic ...
- EasyInvoice 简介
注:本文首发于博客园 EasyInvoice 简介,转载请保留本链接 EasyInvoice(简称 EI) 是一款专门为网上卖家量身打造的管理进销存的软件. 1. 简介 解决卖家日常经营中一直存在的商 ...
- web开发小白之路
今天就来谈谈本人从事web开发的一系列白只又白的经历,本人刚开始是从事ios开发的,由于一系列的变故现在变为了web前端开发,不过说来也奇怪,刚开始接触前端时间可以说是彻底蒙圈,各种选择器,各种适配搞 ...