L1-006. 连续因子
来源:互联网 发布:手腕细 手表 知乎 编辑:程序博客网 时间:2024/05/19 22:03
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<vector>#include<queue>#include<deque>#include<set>#include<map>using namespace std;//动态规划//n%i==0?dp[i-1]+1:0;const int maxn=5*10000;#define INF 0x3f3f3f3ftypedef unsigned long long ll;int dp[maxn];int dis(){ for(int i=1;i<20;i++){ cout<<dp[i]; } cout<<endl;}int main(){ memset(dp,0,sizeof(dp)); int N; cin>>N; int pos=0,cnt=0,n=N;// cout<<n<<endl; for(int i=2;i<maxn-10;i++){ if(n%i==0){ dp[i]=dp[i-1]+1; n=n/i;// cout<<i<<" "<<n<<endl; } else{ int p=i-dp[i-1]; for(int j=p;j<i;j++){ n=n*j; if(n%i==0){ dp[i]=i-j; n/=i; break; } } } if(dp[i]>cnt) cnt=dp[i],pos=i; } // dis(); if(cnt==0&&pos==0){ cout<<1<<endl; cout<<N<<endl; } else{ cout<<cnt<<endl; for(int i=pos-cnt+1;i<pos;i++){ cout<<i<<"*"; } cout<<pos<<endl; } return 0;}
0 0
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- L1-006. 连续因子
- java实现读取TXT文件的方法
- UIView的几个布局方法和重绘
- SSL 1764——最小生成树II
- 迷宫
- python 图表plot样式
- L1-006. 连续因子
- codeup模拟赛 进击的二叉查找数
- 装备选择案例
- 求1!+2!+3!+......10!
- 反射
- java中lang sql util包
- SAP HANA XS 专栏
- c++11::std::unordered_map::demo
- 汇编写冒泡排序