首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
799
2024年3月8日 15:49
质因数个数 题解:
P1156
回复 0
|
赞 1
|
浏览 1.3k
/* 用到2个数组 vector 定义,一个数组用来标记1-n中,是素数的数字;然后遍历,存放1-n素数 */ #include<bits/stdc++.h> using namespace std; vector<int> pn;//素数数组 int prime(int x)//判断素数 { int flag=1;//1是素数 if(x==1) return 0;//0不是素数 for(int j=2;j<=sqrt(...
Cookie‘s AE86
2024年3月2日 16:04
求大佬帮我康康哪里有问题,准确率只有75
P1156
回复 1
|
赞 1
|
浏览 1.5k
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int str[N] = {0}; //0表示是素数 int primenumber[N]; int pncount = 0; int main(){ int n; str[0] = 1; str[1] = 1; //预先求出N以内的素数 for(int i = 2 ;i <= sqrt(N) ;i++){ if(str[i] ==...
小王桐学
2024年2月8日 17:42
质因数个数 题解:C
P1156
回复 0
|
赞 3
|
浏览 1.5k
#include <stdio.h> #include <math.h> int isPrimary(int n) { int i; for(i = 2; i <= sqrt(n); i++) if(n % i == 0) break; if(i > sqrt(n)) return 1; else return 0; } int Prime_Factor(int n) { int i = 2,count = 0; if(isPrimary(n)) return 1;//本身就是质数,单独处理 w...
孙某人
2024年1月25日 23:23
质因数个数 题解:易错点:超时
P1156
回复 0
|
赞 3
|
浏览 1.7k
#include <iostream> #include <math.h> using namespace std; int cc(long long int c){ int index=1; //double c1=c; for(int i=2;i<=sqrt(c*1.0);i++) { if(c%i==0){ index=0; break; } } if(index==0) return 0; else return 1; } int main(){ long long in...
Hegel
2023年3月22日 20:27
分解质因数的个数
P1156
回复 0
|
赞 2
|
浏览 3.8k
#include <iostream> #include <cmath> using namespace std; bool Jud(int a) { if (a <= 1) return false; if (a == 2) return true; for (int i = 2; i < sqrt(a) + 1; i++) if (a % i == 0) return false; return true; } int Cou(int n) { int res = 0,i=2; whi...
myhy001
2020年2月7日 17:24
无输出是哪里错
P1156
回复 2
|
赞 0
|
浏览 11.4k
#include<stdio.h> #include<string.h> #include<math.h> #include<time.h> #include<stdlib.h> int main() { int n; while(scanf("%d",&n)!=EOF) { int count,i,j,k;i=2;count=0; &nbs...
huangdashuaige
2023年2月20日 14:59
P1156 质因数个数
P1156
回复 0
|
赞 2
|
浏览 4.2k
#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
|
浏览 6.1k
#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
|
赞 5
|
浏览 10.3k
#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
|
浏览 11.0k
#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; ...
1
2
3
4
题目
质因数个数
题解数量
33
发布题解
在线答疑
热门题解
1
质因数个数
2
质因数个数 求解:有没有大佬帮我看一下,为什么只有75通过率,超时了
3
质因数个数 题解:
4
质因数个数 题解:二刷优化代码
5
质因数个数 题解:计算机小白的拙劣题解
6
质因数个数(数论)题解:
7
质因数个数 题解:简短的解
8
[c]看了其它人的算法,我觉得有一个思想需要告诉大家。
9
质因数个数 题解:
10
75%的原因:如果本身是质数就要单独处理,否则就会超时