D - 756

Time limit : 2sec / Memory limit : 1024MB

Score : 400 points

Problem Statement

You are given an integer N. Among the divisors of N! (=1×2×…×N), how many Shichi-Go numbers (literally "Seven-Five numbers") are there?

Here, a Shichi-Go number is a positive integer that has exactly 75 divisors.

Note

When a positive integer A divides a positive integer BA is said to a divisor of B. For example, 6 has four divisors: 1,2,3 and 6.

Constraints

  • 1≤N≤100
  • N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

Print the number of the Shichi-Go numbers that are divisors of N!.


Sample Input 1

Copy

9

Sample Output 1

Copy

0

There are no Shichi-Go numbers among the divisors of 9!=1×2×…×9=362880.


Sample Input 2

Copy

10

Sample Output 2

Copy

1

There is one Shichi-Go number among the divisors of 10!=3628800: 32400.


Sample Input 3

Copy

100

Sample Output 3

Copy

543
#include<algorithm> 
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
ll v4=0,v2=0,v14=0,v24=0,v74=0;
bool is_prime(int x){//判断是否为质数 
	if(x==1) return false;
	for(int i=2;i*i<=x;i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
ll C(int m,int n){//组合 
	if(m<n) return 0;
	ll sum=1;
	for(int i=0;i<n;i++){
		sum*=m-i;
	}
	for(int i=2;i<=n;i++){
		sum/=i;
	}
	return sum;
}
int main(){
/*
一个数c=p1^a1*p2^a2*……*pn^an(pi为各个质因数,ai为他们的次数) 
c的因数个数=(a1+1)(a2+1)……(an+1)  
所以Shichi-Go numbers(即因数有75个的数)的情况:
1.
75=3*25 (2,24)
2.
75=3*5*5(2,4,4)
3.
75=5*15 (4,14)
4.
75=75   (74)

且题目要求n!的一个约数是 Shichi-Go numbers
所以该约数是由n!的质因数构成 

案例:n=10,10!=3628800 
 3628800=2^8*3^4*5^2*7
 32400=2^4*3^4*5^2
*/
	ll n;
	int count[101];//count表示n!里面各个质因数出现的次数 
	cin>>n;
	memset(count,0,sizeof(count));
	for(int i=2;i<=n;i++){//将阶乘的每一个数拆分成质因数 
		int t=i;
		for(int j=2;j<=t;j++){
			if(is_prime(j) && t%j==0 && t>1){
				count[j]++;
				t/=j;
				j--;
			}
		}
	}
	for(int i=2;i<=n;i++){
		if(is_prime(i)){
			if(count[i]>=2){
				v2++;
			}
			if(count[i]>=4){
				v4++;
			}
			if(count[i]>=14){
				v14++;
			}
			if(count[i]>=24){
				v24++;
			}
			if(count[i]>=74){
				v74++;
			}
		}
	}
	ll ans=0;
	ans=v74//(74)次数大于74次的质因数随便取一个,设为a,则a^74是一个数 
	+(v4-v14)*v14+(v14-1)*v14//(4,14)分类:1.取的v4中是v14  2.取的v4不是v14 
	+v24*(v2-v24)+(v24-1)*v24//(2,24)分类:1.取的v2中是v24  2.取的v2不是v24 
	+C(v4,2)*(v2-v4)+C(v4-1,2)*v4;//(2,4,4)分类:1.取的v2是v4  2.取的v2不是v4 
	cout<<ans<<"\n";
	return 0;
}

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值