如果是素数直接输出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. 【Python爬虫实战--3】html写正则表达式

    以下是要爬虫的html内容: <div class="article block untagged mb15" id='qiushi_tag_113452216'> & ...

  2. PureLayout

    PureLayout 是 iOS & OS X Auto Layout 的终极 API——非常简单,又非常强大.PureLayout 通过一个全面的Auto Layout API 扩展了 UI ...

  3. jquery-选择checkbox的多种策略

    checkbox属性: var val = $("#checkAll").val();// 获取指定id的复选框的值 var isSelected = $("#check ...

  4. 配置pyqt5环境 for python3.4 on Linux Mint 17.1

    1.安装QT 配置QT PATH 在 /etc/profile文件中追加 export QTDIR=/usr/local/Qt5.4.2/5.4/gcc_64 export LD_LIBRARY_PA ...

  5. ValueStack背后的OGNL表达式

    原文地址:http://blog.csdn.net/li_tengfei/archive/2010/12/25/6098134.aspx 前言: Strut2的Action类通过属性可以获得所有相关的 ...

  6. 存储过程sql语句

    select count(virtualacc) into v_count  from T_ATMMONITOR WHERE virtualacc = v_number; 用于存储过程中,是把coun ...

  7. 小飞淙在博客上的第一天——NOIP201505转圈游戏

    原本我是在word文档上写这种东西的,在杨老师的“强迫”下,我开始写了博客. 这是我在博客上的第一天,就先来个简单的,下面请看题: 试题描述  有n个小伙伴(编号从0到n-1)围坐一圈玩游戏.按照顺时 ...

  8. linux中将程序加入到开机自动启动

    如果将在linux中将命令或者程序设置为开机自动启动,只需要进入到将对应命令加入到/etc/rc.d/rc.local文件里即可,如下 打开文件,vi /etc/rc.d/rc.local #!/bi ...

  9. js第一天 点击按钮显示与隐藏

    <!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...

  10. Java1.5泛型指南中文版(Java1.5 Generic Tutorial)

    Java1.5泛型指南中文版(Java1.5 Generic Tutorial) 英文版pdf下载链接:http://java.sun.com/j2se/1.5/pdf/generics-tutori ...