题意:

输入一个int范围内的正整数,输出它最多可以被分解为多少个连续的因子并输出这些因子以*连接。

trick:

测试点5包含N本身是一个素数的数据,此时应当输出1并把N输出。

测试点5包含一个2e9以上的int整数,此时最好把n当作long long 否则以下代码会运行超时。

AAAAAccepted code:

 #define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int ans[][];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
long long n;
cin>>n;
long long tamp=;
int num=;
int cnt=;
int mx=;
int pos=;
for(long long j=;j*j<=n;++j){
tamp=n;
for(long long i=j;i*i<=n;++i)
if(tamp%i==){
tamp/=i;
ans[num][++cnt]=i;
}
else
break;
if(cnt>mx){
mx=cnt;
pos=num;
}
++num;
cnt=;
}
if(!mx){
cout<<"1\n"<<n;
return ;
}
else{
cout<<mx<<"\n";
for(int i=;i<=mx;++i){
cout<<ans[pos][i];
if(i<mx)
cout<<"*";
}
}
return ;
}

【PAT甲级】1096 Consecutive Factors (20 分)的更多相关文章

  1. PAT甲级——1096 Consecutive Factors (数学题)

    本文同步发布在CSDN:https://blog.csdn.net/weixin_44385565/article/details/91349859 1096 Consecutive Factors  ...

  2. PAT 甲级 1096 Consecutive Factors

    https://pintia.cn/problem-sets/994805342720868352/problems/994805370650738688 Among all the factors ...

  3. PAT Advanced 1096 Consecutive Factors (20) [数学问题-因子分解 逻辑题]

    题目 Among all the factors of a positive integer N, there may exist several consecutive numbers. For e ...

  4. PAT (Advanced Level) Practise - 1096. Consecutive Factors (20)

    http://www.patest.cn/contests/pat-a-practise/1096 Among all the factors of a positive integer N, the ...

  5. PAT甲级——A1096 Consecutive Factors【20】

    Among all the factors of a positive integer N, there may exist several consecutive numbers. For exam ...

  6. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  7. PAT甲级——1152.Google Recruitment (20分)

    1152 Google Recruitment (20分) In July 2004, Google posted on a giant billboard along Highway 101 in ...

  8. 1096. Consecutive Factors (20)

    Among all the factors of a positive integer N, there may exist several consecutive numbers. For exam ...

  9. PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

随机推荐

  1. 解决pycharm创建github工程但push失败的问题

    1.运行git-cmd.exe; 2.d:   cd  工程路径 3.执行命令:git remote set-url origin https://github.com/wawj901124/jmet ...

  2. codeforces 1285D. Dr. Evil Underscores(字典树)

    链接:https://codeforces.com/problemset/problem/1285/D 题意:给n个数a1,a2,a3.....an,找到一个数X,使得X 异或所有的ai ,得到的ma ...

  3. 当你工作与生活迷茫时可以来看看 shuke

    青春是用来奋斗的 很多人在还没工作的时候,总感觉自己有能力会混的不错.毕业几年后,发现社会跟学校完全是两个世界.不经常思考的人,惰性总会让人得过且过混日子,不思考未来的路怎么走,就等于你安于现状,接受 ...

  4. 常用统计分析python包开源学习代码 numpy pandas matplotlib

    常用统计分析python包开源学习代码 numpy pandas matplotlib 待办 https://github.com/zmzhouXJTU/Python-Data-Analysis

  5. 常用bat脚本整理

    在当前文件夹下 shift +鼠标右键 打开终端   输入 tree /f > 1.txt 则将文件夹下的文件名放入1.txt文件中.不包含绝对路径. 要么是写个.bat文件,文件内容为 dir ...

  6. 只要没有给String[]数组new 空间,那么他就只是一个引用

    public class Test1 { @Test public void test(){ String[] values = {"good", "morning&qu ...

  7. Cut Ribbon

    Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the follo ...

  8. Android Socket 通信

    Android socket 通信 安卓编写Socket客户端,实现连接Socket服务端通信. 创建Socket连接并获取服务端数据 先创建几个全局变量吧 private BufferedWrite ...

  9. EAC3 Transient Pre-Noise Processing

    Transient pre-noise processing用于减少pre-noise的长度,pre-noise产生于low bitrate 编码存在transient matiral的场景. 当使用 ...

  10. select poll和 epoll

    select .poll.epoll 都是多路io复用的机制,i/o多路复用就通过一种机制,可以监视多个描述符,一旦某个描述符就绪(一般是读就绪或者写就绪),能够通知乡音的程序进行相应的读写操作.但s ...