题意:

输入一个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. jvm 结构分析

    jvm区域总体分两类,heap区和非heap区.heap区又分: Eden Space(伊甸园).Survivor Space(幸存者区).Tenured Gen(老年代-养老区). 非heap区又分 ...

  2. Element-ui组件库Table表格导出Excel表格

    安装npm install --save xlsx file-saver 两个插件的详细地址在下面 https://github.com/SheetJS/js-xlsxhttps://github.c ...

  3. 用navicate 连接本地数据库提示用户名/口令无效

    1.在用navicate连接本地的oracle数据库时,试了oracle几个默认的用户名和密码,但是当我输入时,却提示用户名/口令无效.所以按照网上的办法,cmd,输入了以下命令,修改了几个用户的用户 ...

  4. vga显示原理即相关计算

    行扫描周期:完成一行扫描所需时间: 行时序时间(a,b,c,d,e):完成一个像素点显示得时间 场扫描周期:完成所有行(一帧扫描所需时间) 场时序时间(o,p,q,r,s):完成一行显示得时间,一个完 ...

  5. Oracle存储过程----存储过程执行简单的增删改查

    1.存储过程执行增加的sql create or replace procedure test_add(id varchar,name varchar,time varchar,age varchar ...

  6. Flink读写Kafka

    Flink 读写Kafka 在Flink中,我们分别用Source Connectors代表连接数据源的连接器,用Sink Connector代表连接数据输出的连接器.下面我们介绍一下Flink中用于 ...

  7. Linux - Shell - #!/bin/bash

    概述 简单解释一下 shell 脚本卡头的 #!/bin/bash 水一篇, 少一篇 背景 shell 脚本中的注释 通常是 以# 卡头的行 但是有时候执行 shell 的时候, 会有这种内容 #!/ ...

  8. EAC3 Transient Pre-Noise Processing

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

  9. AC3 exponent coding

    1.overview AC-3编码的audio信号中的频率系数由浮点型数据表示,并将其归一化到0~1之间. transform coefficient由exponent和mantissa组成. 设tr ...

  10. 揭秘jQuery-选择器

    先看代码: $(“li”)只选择第一个无序列表中的一个li元素,而不会选择另一个无序列表中的li元素 <!DOCTYPE html> <html> <head> & ...