Codevs 1792 分解质因数
来源:互联网 发布:linux系统品牌 编辑:程序博客网 时间:2024/06/02 13:08
不知道还有没有更优的算法……虽然我的能过……
求教QAQ。
代码:
#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <cmath>#include <ctime>#define X CLOCKS_PER_SECusing namespace std;typedef long long LL;bool Judge(LL x){ if(x <= 1) return false; if(x <= 3) return true; for(LL i = 2; i <= sqrt(x); i ++) if(x%i == 0) return false; return true;}int main(){ LL n; cin >> n; printf("%lld=", n); if(Judge(n)) { printf("%lld\n",n); return 0; } bool first = 1; LL i = 2; while(n && n != 1) { if(!Judge(i)) { i ++; continue; } LL cnt = 0; while(n%i == 0) { cnt ++; n/= i; } while(cnt --) { if(!first) printf("*%lld", i); else { printf("%lld", i); first = 0; } } i ++; } return 0;}// 1000000007
0 0
- Codevs 1792 分解质因数
- 【CodeVS】1792 分解质因数
- Codevs 1313 质因数分解
- codevs 1313,1792,3164 分解质因数(埃氏筛法)
- 1792 分解质因数
- 分解质因数
- 分解质因数
- 质因数分解
- 分解质因数
- 质因数分解
- 分解质因数
- 分解质因数
- 质因数分解
- 分解质因数
- 分解质因数
- 分解质因数
- 分解质因数
- 分解质因数
- 属性动画+snakebar+toast+dialog
- 关键帧的边缘检测
- Leetcode 169 Majority Element
- Netty5用户手册之三:使用netty实现EchoServer程序
- reactnative导入了module包,在setting.gradle下的错误
- Codevs 1792 分解质因数
- JAVA-3 数组
- C语言自增减问题总结
- vim修改文件格式,查看不可见字符等
- Http首部字段
- Observable.interval()不起作用的解决办法
- 不用第三方工具解压缩msi文件提取文件
- 北大青鸟视频宣传片列表
- 小码哥杯java程序比赛复习(二)内部类