如果是素数直接输出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. append()常见错误

    实例1 empty = [] print empty.append("Hi") 输出None print empty 输出["Hi"] 错误: 直接打印变量带a ...

  2. docker network

    前言:前面的部分一直都是单机跑docker,但实际生产环境不可能只用一台来跑.肯定会用到多台,因为他们都是内部私有ip,那么多台主机之间的容器如何通信?这个是个很头疼的问题!目前主流几种方法如下: 1 ...

  3. UVA 11021 /概率

    题意: 有k只鸟,每只鸟只能活一天,它可以在死之前生[0,n-1]只鸟,生出x只鸟的概率是p[x].问m天后所有的鸟都时光的概率.(m天之前就死了的也算上). 输入:T.n.k.m. 题解: 每只鸟的 ...

  4. oracle 同义词

    同义词概念 Oracle的同义词(synonyms)从字面上理解就是别名的意思,和视图的功能类似,就是一种映射关系.它可以节省大量的数据库空间,对不同用户的操作同一张表没有多少差别;它扩展了数据库的使 ...

  5. 查看apk包及Activity名方法

    查看apk包名方法activity名: 方法一: aapt dump badging +客户端包所在路径+客户端包名称 如: aapt.exe dump badging K:\Apk\fanxing. ...

  6. Mysql 本地计算机无法启动 mysql 服务 错误 1067:进程意外终

    1.重装后启动mysql服务,提示 本地计算机无法启动 mysql 服务 错误 1067:进程意外终止. 2.查看mysql根目录下有一 计算机名.err 打开一看全是英文的错误提示: 3.根据其中的 ...

  7. OPENWRT make defconfig错误之一

    make defconfig rm: cannot remove `tmp/.host.mk': Permission denied 退到trunk上级目录 su root sudo chown -R ...

  8. spark第二篇--基本原理

    ==是什么 == 目标Scope(解决什么问题) 在大规模的特定数据集上的迭代运算或重复查询检索 官方定义 aMapReduce-like cluster computing framework de ...

  9. 使用AOP 使C#代码更清晰

    简介 如果你很熟悉面向方面编程(AOP),你就会知道给代码增加"切面"可以使代码更清晰并且具有可维护性.但是AOP通常都依赖于第三方类库或者硬编码的.net特性来工作.虽然这些实现 ...

  10. Git的Bug分支----临时保存现场git stash

    软件开发中,bug就像家常便饭一样,有了bug就需要修复,在Git中,由于分支是如此的强大,所以每个bug通过一个新的分支来修复,在修复后,合并分支,然后将临时分支删除. 当你接到一个修复代号为119 ...