首页
DreamJudge
院校信息
考研初试
机试真题
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
huangdashuaige
2023年2月20日 14:59
P1156 质因数个数
P1156
回复 0
|
赞 2
|
浏览 3.8k
#include <iostream> #include <math.h> using namespace std; int main(){ //此为暴力解;核心思想:非质因数必定也可以分解成质因数 //还有一个思路(的核心)是:素数筛选存放到一个数组 long long N;//10^9,条件性使用long long;但看了结果使用int也可以,N为输入正整数 while(cin>>N)...
ajh666
2022年3月20日 20:07
我看大家给的方法基本没有提前打表,在这里分享一个素数筛打表的方法
P1156
回复 0
|
赞 0
|
浏览 5.7k
#include<iostream> #include<string> #include<cmath> #include<algorithm> #include<set> using namespace std; int a[100000] = { 0 }; int main() { int i, j, k; long long n, t, m; for (i = 2; i <= sqrt...
sincerely_LM
2021年3月10日 20:42
75%的原因:如果本身是质数就要单独处理,否则就会超时
P1156
回复 0
|
赞 4
|
浏览 9.8k
#include <iostream> #include <math.h> using namespace std; int FindBigX(int x,int y); int judge(int Num); int main(int argc, char const *argv[]) { int N,count; while(cin>>N) { count=0; int i=2; if (judge(N)) { ...
James
2021年1月29日 17:22
质因子分解
P1156
回复 0
|
赞 0
|
浏览 10.8k
#include <iostream> #include <math.h> #include <stdio.h> using namespace std; int main(){ int n; while(scanf("%d",&n)!=EOF){ int i=2; int k=0; ...
lihui_striver
2020年8月26日 15:25
简单的题解
P1156
回复 0
|
赞 2
|
浏览 8.6k
#include<bits/stdc++.h> using namespace std; const int maxn=1e3+7; int main(){ int n; while(cin>>n){ int cnt=0; for(int i=2;i*i<=n;i++){ while(n%i==0){ n/=i; cnt++; } } ...
Lucky_Bug
2020年4月10日 20:33
[c]看了其它人的算法,我觉得有一个思想需要告诉大家。
P1156
回复 15
|
赞 10
|
浏览 15.1k
看很多人都是把质数单拎出来,这样其实并不对,因为也会存在很大的质数。所以其中的精髓应该是了解:例如:2和3是一个较小的质数,所以如果每次都从2开始的话,这样子永远求得的都是质数而不会有非质数,因为如果想把4或者6作为因数的话,首先会被先试验的2所分解掉。所以不会出现非质数的情况。 #include<stdio.h> int main() { int N; int step = 0; int i = 2; while(scanf("%d",&N)!=EOF) { step = 0; if(N==1) { p...
快乐编程
2020年2月10日 16:02
代码可能有点长,算法可能不好,望见谅
P1156
回复 0
|
赞 0
|
浏览 10.5k
#include<iostream> #include<iomanip> using namespace std; int judgePrime(long long n) { if ((n > 5 || n == 4) && (n % 2 == 0 || n % 3 == 0 || n % 5 == 0)) return 0; else ...
1
2
3
题目
质因数个数
题解数量
27
发布题解
在线答疑
热门题解
1
质因数个数
2
质因数个数 题解:二刷优化代码
3
质因数个数 求解:有没有大佬帮我看一下,为什么只有75通过率,超时了
4
质因数个数 题解:计算机小白的拙劣题解
5
质因数个数(数论)题解:
6
质因数个数 题解:简短的解
7
[c]看了其它人的算法,我觉得有一个思想需要告诉大家。
8
质因数个数 题解:
9
质因数个数 题解:
10
75%的原因:如果本身是质数就要单独处理,否则就会超时