Problem Description Everybody knows any number can be combined by the prime number. Now, your task is telling me what position of the largest prime factor. The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3, etc. Specially, LPF(1) = 0. Inpu…
Largest prime factor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13481    Accepted Submission(s): 4765 Problem Description Everybody knows any number can be combined by the prime number.Now,…
题目梗概:求1000000以内任意数的最大质因数是第几个素数,其中 定义 1为第0个,2为第1个,以此类推. #include<string.h> #include<stdio.h> #include<math.h> ],b[],c[];//b[i]表示i是第几个素数,c[k]表示k的最大素数是c[k],a[i]表示是不是素数 int main() { int n,i,num,j; memset(a,,sizeof(a)); a[]=; b[]=; num=; ;i&l…
题意:给你一个数,让你求它的最大因子在素数表的位置. 析:看起来挺简单的题,可是我却WA了一晚上,后来终于明白了,这个第一层循环不是到平方根, 这个题和判断素数不一样,只要明白了这一点,就很简单了. 代码如下: #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <cstring>…
#include <iostream> #include <vector> #include <cmath> using namespace std; const int MAX=1000001; bool isPrime[MAX];//isPrime[i]=true表示是素数,false表示不是 int indexes[MAX]; //存放素数因子的序号 void eraosthenes() { fill(isPrime,isPrime+MAX,true);//如果0…
题目大意:求出比给出数小的互质的质数个数. 题解:直接用筛法求素数,稍微改编一下,将原先的布尔数组变为数组用来记录信息就可以了. 注意点:大的数组定义要放在程序的开头,不要放在main里面,不然会栈溢出. #include <cstdio> #define max 1000000 }; int main() { int n; ; ; i<max; ++i) { if(prim[i]) continue; for(int j=i; j<max; j+=i) prim[j]=cnt;…
Problem Description Everybody knows any number can be combined by the prime number.Now, your task is telling me what position of the largest prime factor.The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3, etc.Specially, LPF(1) = 0.   Input…
Largest prime factor Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6990    Accepted Submission(s): 2471 Problem Description Everybody knows any number can be combined by the prime number. Now…
Everybody knows any number can be combined by the prime number. Now, your task is telling me what position of the largest prime factor. The position of prime 2 is 1, prime 3 is 2, and prime 5 is 3, etc. Specially, LPF(1) = 0.  InputEach line will con…
/*打表把素数能组合的数先设置成相应的位数*/ /* if n equals two and n is No.1 position of prime factors  so four position of prime factors is no.1,as well*/ /* although two can combined six but three also can combined six */ /* and three position of prime factors is two…