X-factor Chains
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6501   Accepted: 2023

Description

Given a positive integer X, an X-factor chain of length m is a sequence of integers,

1 = X0X1X2, …, Xm = X

satisfying

Xi < Xi+1 and Xi | Xi+1 where a | b means a perfectly divides into b.

Now we are interested in the maximum length of X-factor chains and the number of chains of such length.

Input

The input consists of several test cases. Each contains a positive integer X (X ≤ 220).

Output

For each test case, output the maximum length and the number of such X-factors chains.

Sample Input

2
3
4
10
100

Sample Output

1 1
1 1
2 1
2 2
4 6
思路:将x进行质因数分解,X-factor Chains中(第因一项永为1,所以不计)第i项就是将质因数进行排列后前i项的积。所以length为质因数的个数。numbeu为质因数全排列的种数。相同质因数之间的排列要去重。
#include <iostream>
#include <map>
using namespace std;
typedef unsigned long long ull;
map<int,int> prime_factor(int n)//质因数分解
{
map<int,int> res;
for(int i=;i*i<=n;i++)
{
while(n%i==)
{
res[i]++;
n/=i;
}
}
if(n!=)
{
res[n]++;
}
return res;
}
ull fact(int n)
{
ull res=;
for(int i=;i<=n;i++)
{
res*=i;
}
return res;
}
int x;
int main()
{
while(cin>>x)
{
map<int,int> res=prime_factor(x);
int len=;
for(map<int,int>::const_iterator it=res.begin();it!=res.end();it++)
{
len+=it->second;
}
ull cnt=fact(len);
for(map<int,int>::const_iterator it=res.begin();it!=res.end();it++)
{
cnt/=fact(it->second);//去重
}
cout<<len<<" "<<cnt<<endl;
}
return ;
}

POJ3421(质因数分解)的更多相关文章

  1. POj3421 X-factor Chains(质因数分解+排列组合)

    POj3421X-factor Chains 一开始没读懂题意,不太明白 Xi | Xi+1 where a | b means a perfectly divides into b的意思,后来才发现 ...

  2. 求n!质因数分解之后素数a的个数

    n!质因数分解后P的个数=n/p+n/(p*p)+n/(p*p*p)+......直到n<p*p*p*...*p //主要代码,就这么点东西,数学真是厉害啊!幸亏我早早的就退了数学2333 do ...

  3. AC日记——质因数分解 1.5 43

    43:质因数分解 总时间限制:  1000ms 内存限制:  65536kB 描述 已知正整数 n 是两个不同的质数的乘积,试求出较大的那个质数. 输入 输入只有一行,包含一个正整数 n. 对于60% ...

  4. 【BZOJ-4514】数字配对 最大费用最大流 + 质因数分解 + 二分图 + 贪心 + 线性筛

    4514: [Sdoi2016]数字配对 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 726  Solved: 309[Submit][Status ...

  5. 整数分解 && 质因数分解

    输入整数(0-30)分解成所有整数之和.每四行换行一次. 一种方法是通过深度优先枚举出解.通过递归的方式来实现. #include <stdio.h> #include <strin ...

  6. algorithm@ 大素数判定和大整数质因数分解

    #include<stdio.h> #include<string.h> #include<stdlib.h> #include<time.h> #in ...

  7. POJ1365 - Prime Land(质因数分解)

    题目大意 给定一个数的质因子表达式,要求你计算机它的值,并减一,再对这个值进行质因数分解,输出表达式 题解 预处理一下,线性筛法筛下素数,然后求出值来之后再用筛选出的素数去分解....其实主要就是字符 ...

  8. 数学概念——J - 数论,质因数分解

    J - 数论,质因数分解 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit ...

  9. hdu1405 第六周J题(质因数分解)

    J - 数论,质因数分解 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Desc ...

随机推荐

  1. linux输入子系统简述【转】

    本文转载自:http://blog.csdn.net/xubin341719/article/details/7678035 1,linux输入子系统简述 其实驱动这部分大多还是转载别人的,linux ...

  2. JAVA 集成 Ueditor 百度富文本编辑器

    开发环境:一个简单的SpringMVC框架中,用百度富文本编辑器 ueditor 实现图片和文件的上传 官网地址:http://ueditor.baidu.com/website/ 需要使用到的2个文 ...

  3. Luogu-4774 [NOI2018]屠龙勇士

    这题好像只要会用set/平衡树以及裸的\(Excrt\)就能A啊...然而当时我虽然看出是\(Excrt\)却并不会...今天又学了一遍\(Excrt\),趁机把这个坑给填了吧 现预处理一下,找出每条 ...

  4. 智能穿戴设备移动APP端与外设数据传输协议

    S1 Communication Layer specifications 1. Purpose of This Document                                    ...

  5. Flume-NG启动过程源码分析(一)(原创)

    从bin/flume 这个shell脚本可以看到Flume的起始于org.apache.flume.node.Application类,这是flume的main函数所在. main方法首先会先解析sh ...

  6. ANT+JMETER集成2 (发送邮件)

    折腾一天发现各种build源码都不能发送邮件,试了很多次,终于能发送邮件 先看成果 build源码贴出来 <?xml version="1.0" encoding=" ...

  7. 【疯了Labview】(一)仿JKI的RCF 挂件

    最近在疯狂的学习C#中,学习的最好的一个途径便是论坛,发帖,看帖和被骂,新手往往在这个过程中慢慢长大一直想做个类似JKI RCF挂件的东西,目前实现了,想想其实思路也不是很难, RCF是JKI做的通过 ...

  8. if 条件判断 和 判断总结---shell脚本

    本文主要介绍了Shell脚本IF条件判断和判断条件总结,本文先是给出了IF条件判断的语法,然后给出了常用的判断条件总结,需要的朋友可以参考下. 前言: 无论什么编程语言都离不开条件判断.SHELL也不 ...

  9. PostMan使用教程(1)

    Postman介绍 Postman是google开发的一款功能强大的网页调试与发送网页HTTP请求,并能运行测试用例的的Chrome插件.其主要功能包括: 模拟各种HTTP requests 从常用的 ...

  10. 解决:easygui.msgbox("Hello there!")报错:Tcl_Init error: Can't find a usable init.tcl in the following directories问题的解决

    今天学习<父与子的编程之旅>,当看到运行第一个gui时(代码如下): import easygui easygui.msgbox("Hello there!") 发现报 ...