poj2649 Factovisors 质因数分解

编程入门 行业动态 更新时间:2024-10-23 06:22:20

poj2649 Factovisors <a href=https://www.elefans.com/category/jswz/34/1722675.html style=质因数分解"/>

poj2649 Factovisors 质因数分解

需注意,判定的时候应该是分解出一个m的质因子就比较一次,而不是分解完后再比较,细节上处理要注意,比如当pr[i]不属于m的质因子时直接跳过,这样当m为一个大质数的时候不至于runtimr error

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define maxn 100001
using namespace std;
bool valid[maxn];
int pr[100001],coun=0,n,m;
void Init()
{valid[1]=1;for(int i=2;i<maxn;i++){if(!valid[i])pr[coun++]=i;for(int j=2;i*j<maxn;j++)valid[i*j]=1;}
}
bool Check(int num,int counter)
{int coun=0;for(int i=num;i<=n;i++){int a=i;while(a%num==0){a/=num;coun++;}if(coun>=counter){return true;}}return false;
}
int main()
{Init();while(~scanf("%d%d",&n,&m)){bool ans=1;int s=m,now=0

更多推荐

poj2649 Factovisors 质因数分解

本文发布于:2024-02-06 03:48:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1746127.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:质因数   分解   Factovisors

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!