如果是素数直接输出1与素数,否则枚举长度和起始数即可。

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std; long long n; bool prime(long long x)
{
if(x==) return ;
if(x==) return ;
for(long long i=; i*i<=x; i++)
{
if(x%i==) return ;
}
return ;
} int main()
{
scanf("%lld",&n);
int f=; if(prime(n))
{
printf("1\n");
printf("%lld\n",n);
}
else
{
for(int len=; len>=; len--)
{
long long num=;
for(long long i=;; i++)
{
if(i==)
{
for(long long j=i; j<=i+(long long)len-; j++)
{
num=num*j;
if(num>n) break;
}
}
else num=num/(i-)*(i+len-); if(num>n) break;
if(n%num==)
{
f=;
printf("%d\n",len);
for(long long j=i; j<=i+len-; j++)
{
printf("%lld",j);
if(j<i+len-) printf("*");
}
printf("\n");
break;
}
}
if(f==) break;
}
}
return ;
}

PAT (Advanced Level) 1096. Consecutive Factors (20)的更多相关文章

  1. 【PAT甲级】1096 Consecutive Factors (20 分)

    题意: 输入一个int范围内的正整数,输出它最多可以被分解为多少个连续的因子并输出这些因子以*连接. trick: 测试点5包含N本身是一个素数的数据,此时应当输出1并把N输出. 测试点5包含一个2e ...

  2. PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...

  3. PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1008 Elevator (20 分) 凌宸1642 题目描述: The highest building in our city has ...

  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 Advanced 1096 Consecutive Factors (20) [数学问题-因子分解 逻辑题]

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

  6. 1096. Consecutive Factors (20)

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

  7. PAT甲题题解-1096. Consecutive Factors(20)-(枚举)

    题意:一个正整数n可以分解成一系列因子的乘积,其中会存在连续的因子相乘,如630=3*5*6*7,5*6*7即为连续的因子.给定n,让你求最大的连续因子个数,并且输出其中最小的连续序列. 比如一个数可 ...

  8. PAT (Advanced Level) Practice 1035 Password (20 分)

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

  9. 【PAT Advanced Level】1008. Elevator (20)

    没什么难的,简单模拟题 #include <iostream> using namespace std; int main() { int num; cin>>num; int ...

随机推荐

  1. PHP CURL 代理发送数据

    $session = curl_init($request); curl_setopt ($session, CURLOPT_PROXY, $proxy); curl_setopt ($session ...

  2. Pots(BFS)

    Pots Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submiss ...

  3. thinkPHP框架学习笔记

    class ZhuantiAction extends Action { public function index() { $name = trim($this->_get('name')); ...

  4. 免费开源的boostrap模板

    百度查不到,奶奶的,百度好多国外技术类文章的都查不到 https://colorlib.com/wp/free-html5-admin-dashboard-templates/ 有没有FQ软件介绍呀?

  5. ajaxpro——js调用后台的方法

    前提:添加并引用类库ajaxpro.dll 1.把引用的类库改为自己(如果是自己的话,就不用修改): <%@ Page Language="C#" AutoEventWire ...

  6. samba连接提示“找不到网络路径”

    在运行里面输入services.msc,打开服务管理界面. 根据服务的描述,找到了TCP/IP NetBIOS Helper服务描述中提到TCP/IP NetBIOS Helper服务能使用户能够共享 ...

  7. Activity LauchMode启动模式(转载)

    转载于:http://www.cnblogs.com/plokmju/p/android_ActivityLauncherMode.html 在一个Android应用中,不可避免的会包含多个Activ ...

  8. java学习第21天(IO流的使用)

    IO流分类: A:流向 输入流 读取数据 输出流 写出数据 B:数据类型 字节流 字节输入流 字节输出流 字符流 字符输入流 字符输出流 注意: a:如果我们没有明确说明按照什么分,默认按照数据类型分 ...

  9. VBS控制鼠标移动和点击(附源代码下载)

    森思:想用vbs来控制鼠标的移动和点击,虽然按键精灵可以做到,但做这么简单的事情不想启动那么大一个程序,所以自己用VC写了一个小程序,可以让VBS来控制鼠标移动和点击. 用法: 移动鼠标到桌面坐标20 ...

  10. C#中Bitmap类 对图像の操作 可检测图片完整性

    try { Bitmap bm = new Bitmap(pics[ip]); BitmapToBytes(bm).Reverse().Take(2); } catch (Exception ex) ...