PAT_1059. Prime Factors
来源:互联网 发布:淘宝开店一定要交保证金吗 编辑:程序博客网 时间:2024/06/08 02:10
//// main.cpp// PAT_1059. Prime Factors//// Created by wjq on 17/5/16.// Copyright © 2017年 wjq. All rights reserved.//#include <iostream>using namespace std;long long int N;int flag=0;int main(int argc, const char * argv[]){ cin>>N; cout<<N<<"="; for(int i=2;i*i<=N;i++) { int num=0; //cout<<"N="<<N<<" i="<<i<<" N%i="<<N%i<<endl; while(N%i==0) { N/=i; num++; } //cout<<"N="<<N<<endl; if(num!=0) { if(flag==1) printf("*"); else flag=1; if(num>1) printf("%d^%d",i,num); else printf("%d",i); } } if(flag==1) { if(N>1) printf("*%lld",N); } else printf("%lld",N); return 0;}
分解质因子,输出格式注意一下就好.
阅读全文
0 0
- PAT_1059: Prime Factors
- PAT_1059. Prime Factors
- Prime Factors
- Prime Factors
- Prime Factors
- Prime Factors
- UVa 583-Prime Factors
- 1059. Prime Factors
- UVa 583 - Prime Factors
- 1059. Prime Factors (25)
- 1059. Prime Factors (25)
- PAT 1059. Prime Factors
- 1059. Prime Factors
- 1059. Prime Factors (25)
- 1059. Prime Factors
- 1059. Prime Factors (25)
- 1059. Prime Factors (25)
- PAT 1059. Prime Factors
- 文章标题
- 【算法-java】打印出二叉树中结点值的和为输入整数的所有路径
- 如何向MVC5项目中添加Wep API
- STL之queue容器
- 一个带清除按钮的EditText-->ClearEditText
- PAT_1059. Prime Factors
- iOS开发之GCD使用总结
- 程序员找工作要有哪些面试技巧
- 如何获取app(apk和ipa)中的资源
- 《UNIX网络编程卷1:套接字联网API 中文高清第3版(带完整书签)》pdf
- html5中的Web Storage(sessionStorage、localStorage)
- scapy
- Combiners
- Oracle中插入记录的方法