题意:

输入一个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. 较完整checkstyle.xml及说明

    具体项的具体说明请参考:https://www.cnblogs.com/ziyuyuyu/p/9870717.html 梳理此次完整checkstyle.xml说明,以备以后再此基础上删减 <? ...

  2. leetcode全部滑动窗口题目总结C++写法(完结)

    3. 无重复字符的最长子串 A: 要找最长的无重复子串,所以用一个map保存出现过的字符,并且维持一个窗口,用le和ri指针标识.ri为当前要遍历的字符,如果ri字符在map中出现过,那么将le字符从 ...

  3. Android Studio的第一次运行

    一.开发软件的下载 下载教程 https://blog.csdn.net/bzlj2912009596/article/details/87280191 下载地址 http://www.android ...

  4. 第五十二篇 Linux相关——数据库服务MySQL

        No.1. MySQL基本操作 CentOS7默认安装mariadb数据库,先将其移除 移除命令:sudo yum -y remove mariadb-libs.x86_64 下载MySQL源 ...

  5. Visual Studio 2015创建ASP.NET MVC流程

    本文链接:https://blog.csdn.net/begindong/article/details/68059437本人这两天第一次对c#进行系统学习,写出来做个学习记录和大家分享,以下有什么错 ...

  6. jmeter+ant+jenkins接口自动化测试框架

    大致思路:Jmeter可以做接口测试,也能做压力测试,而且是开源软件:Ant是基于Java的构建工具,完成脚本执行并收集结果生成报告,可以跨平台,Jenkins是持续集成工具.将这三者结合起来可以搭建 ...

  7. python多进程编程学习笔记

    摘自[https://www.cnblogs.com/chenhuabin/p/10070996.html] by 奥辰 赞

  8. 问题 D: 家庭问题

    问题 D: 家庭问题 时间限制: 1 Sec  内存限制: 128 MB[命题人:admin] 题目描述 有n个人,编号为1,2,……n,另外还知道存在K个关系.一个关系的表达为二元组(α,β)形式, ...

  9. 【资源分享】Gmod动态方框透视脚本

    *----------------------------------------------[下载区]----------------------------------------------* ...

  10. 使用js处理后台返回的Date类型的数据

    从后台返回的日期类型的数据,如果直接在前端进行显示的话,显示的就是一个从 1970-01-01 00:00:00到现在所经过的毫秒数,而在大多数业务中都不可能显示这个毫秒数,大多数都是显示一个正常的日 ...