HDU 1164(质因子的分解)
来源:互联网 发布:云计算运维工程师简历 编辑:程序博客网 时间:2024/05/10 03:18
题意:如题。
#include<iostream>#include<math.h>using namespace std;const int maxn=65536;int plist[7000];bool flag[maxn];int i;void init(){ int max=(int)sqrt(maxn*1.0); memset(flag,true,sizeof(flag)); for(i=2;i<=max;i++) { if(flag[i]) for(int j=i*i;j<=maxn;j+=i) flag[j]=false; } int count=0; for(i=2;i<=maxn;i++) if(flag[i]) { plist[count]=i; count++; } //cout<<count<<" "<<plist[count-1]<<endl;}int main(){ int n; init(); //cout<<plist[0]<<endl; while(scanf("%d",&n)!=EOF) { int index=0; while(n>=plist[index]) { //cout<<index<<" "<<plist[index]<<" "<<n<<endl; if(n%plist[index]==0) { n=n/plist[index]; if(n!=1) printf("%d*",plist[index]); else printf("%d\n",plist[index]); //cout<<plist[index]<<" "<<n<<endl; } else { index++; } } //cout<<plist[index]<<" "<<n<<endl; } return 0; }
0 0
- HDU 1164(质因子的分解)
- hdu-1164涮素数+质因子分解
- hdu 4139 质因子分解
- HDU 2421 质因子分解
- hdu 2421 分解质因子
- hdu 5428(分解质因子)
- 质因子的分解
- n!的质因子分解
- N!的质因子分解
- HDU 3864 pollard_rho大数质因子分解
- hdu 5428 the factor(分解质因子)
- HDU 5428-The Factor(分解质因子)
- HDU 6069 素数筛+分解质因子
- hdu 1164 质因子分解 (筛素数模板)+ hdu 1215
- HDU 4135&HDU 4407--容斥原理--质因子分解
- HDU 1333 分解素数因子
- 整数因子的分解
- 【HDU】4135 Co-prime(容斥原理简单应用 质因子的分解)
- Shell学习
- gocode 安装
- HDU4778
- Dotfuscator Professional Edition 4.9.7500.9484 破解版+使用教程(.NET混淆工具)
- cocos2d-x动作、特效和动画(二)缩放动作
- HDU 1164(质因子的分解)
- HDU4545
- Ubuntu x64 下安装Qt sdk 1.2.1 系统卡死
- Zend Framework 2 : Event and DI
- HDU4639
- iOS中Block介绍(一)基础
- HDU 4496 D-CITY(并查集)
- 找出一堆球中唯一最轻者
- 协同过滤推荐(CF)