逆袭指数-——杭电校赛(dfs)
逆袭指数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 626 Accepted Submission(s): 94
尽管身处逆境,但小明一直没有放弃努力,除了搬砖,小明还研究过东方的八卦以及西方的星座,一直试图在命理上找到自己能够逆袭的依据。
当这些都失败以后,小明转向了数学研究,希望从中得到一些信息。一天,小明在研究《BestCoder逆袭的数理基础》这本书时,发现了宝贵的信息,其中写道:
每个人都存在一个逆袭指数,对于这个逆袭指数,可能存在连续的因子,如果这个连续因子足够长的话,那么这个人逆袭的概率就很大!
小明已知自己的逆袭指数,请告诉小明他最长的连续因子,以让他来判断他自己是否能够逆袭。
每组数据占一行,包含一个整数N,表示小明的逆袭指数,N小于2^31。
第一行输出最长的因子个数;
第二行输出最小的因子序列,具体请参考样例。
特别说明:由于小明十分讨厌单身,所以1不算因子。
12
5*6*7
2
2*3
630 = 3*5*6*7
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
using namespace std;
const int INF = 1e9+;
int a[],Max=,b[]; void dfn(int n,int k,int l)
{
if(n%k== && n!=)
{
a[l]=k;
dfn(n/k,k+,l+);
}
else if(Max<l)
{
Max=l;
for(int i=;i<l;i++)
{
b[i]=a[i];
}
}
} int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
int len=sqrt(n);
Max=;
for(int i=;i<=len;i++)
{
dfn(n,i,);
}
if(Max== && n!=)
{
Max=;
b[]=n;
}
printf("%d\n",Max);
printf("%d",b[]);
for(int i=;i<Max;i++)
{
printf("*%d",b[i]);
}
printf("\n");
}
return ;
}
逆袭指数-——杭电校赛(dfs)的更多相关文章
- 搬砖--杭电校赛(dfs)
搬砖 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submissi ...
- ACM组队安排-——杭电校赛(递推)
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #in ...
- hdu 逆袭指数
Problem Description 这依然是关于高富帅小明曾经的故事—— 尽管身处逆境,但小明一直没有放弃努力,除了搬砖,小明还研究过东方的八卦以及西方的星座,一直试图在命理上找到自己能够逆袭 ...
- 杭电1010(dfs + 奇偶剪枝)
题目: The doggie found a bone in an ancient maze, which fascinated him a lot. However, when he picked ...
- Sum It Up POJ 1564 HDU 杭电1258【DFS】
Problem Description Given a specified total t and a list of n integers, find all distinct sums using ...
- [杭电新生赛]hgame-week1-web-wp
hgame第一周总结 (官方wp更加简洁明了.直入主题,个人比较菜,所以过程繁琐 写好了一直没发qwq(就是懒(bushi) 一.Tetris plus! 题目里说玩到3000分就给flag,还真有点 ...
- 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)
以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...
- ACM 五一杭电赛码"BestCoder"杯中国大学生程序设计冠军赛小记
对于这项曾经热爱的竞赛,不得不说这是我最后一年参加ACM比赛了,所以要珍惜每一次比赛的机会. 五一去杭电参加了赛码"BestCoder"杯中国大学生程序设计冠军赛,去的队伍包括了今 ...
- 2018 Multi-University Training Contest 1 杭电多校第一场
抱着可能杭电的多校1比牛客的多校1更恐怖的想法 看到三道签到题 幸福的都快哭出来了好吗 1001 Maximum Multiple(hdoj 6298) 链接:http://acm.hdu.edu. ...
随机推荐
- ASP.NET Core MVC使用MessagePack配合前端fetch交换数据
1.安装Nuget包 - WebApiContrib.Core.Formatter.MessagePack https://www.nuget.org/packages/WebApiContrib.C ...
- SpringBoot2.1.3修改tomcat参数支持请求特殊符号
最近遇到一个问题,比如GET请求中,key,value中带有特殊符号,请求会报错,见如下URL: http://xxx.xxx.xxx:8081/aaa?key1=val1&a.[].id=1 ...
- [BZOJ1046][HAOI2007]上升序列 DP+贪心
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1046 我们先求出对于每一个数字作为开头的LCS的长度f[i],最长的f[i]为mxlen. ...
- iOS Programming UIWebView 2
iOS Programming UIWebView 1 Instances of UIWebView render web content. UIWebView可以显示web content. In ...
- leetcode_1015. Numbers With Repeated Digits
https://leetcode.com/problems/numbers-with-repeated-digits/ 与leetcode_357. Count Numbers with Unique ...
- 删数问题(Noip1994)
1321:[例6.3]删数问题(Noip1994) 时间限制: 1000 ms 内存限制: 65536 KB提交数: 5127 通过数: 1595 [题目描述] 输入一个高精度 ...
- element-UI el-table二次封装
Part.1 为什么要二次封装? 这是 Element 网站的 table 示例: <template> <el-table :data="tableData" ...
- ms_sql 触发器记录表字段数据变化的日志 -针对一张表操作
create table sto (id int not null, -- 主键字段 de datetime -- 被跟踪的字段 constraint pk_sto primary key(id)) ...
- [Algorithm] 1. A+B Problem
Description Write a function that add two numbers A and B. Clarification Are a and b both 32-bit int ...
- buf.values()
buf.values() 返回:{Iterator} 创建并返回一个包含 Buffer 值(字节)的迭代器.当 Buffer 使用 for..of 声明时将自动调用该函数. const buf = B ...