题意描述:
在不超过n!的数中有多少个数恰好含有75个因子。
题解:
75=5*5*3=15*5=25*3=75
我们知道一个数可以分解成多个质因数的乘积。
因此可以想到75个因子可以是质因子个数的排列组合。
如当n=10时
2的个数最多是8个,3的个数是4个,5的个数有2个,7的个数有1个
只能凑出一个(4+4+1)所以答案是1
因此此题可以化简成将n!分解质因数,统计每个质因数的个数 配对75的因式分解情况 进行排列组合。
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 B, A 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 <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
using namespace std;
bool vis[200];
int que[100],sum[100];
int tot;
void get(){
tot=0;
for(int i=2;i<=100;i++){
int tmp=i*i;
if(!vis[i]){
que[++tot]=i;
//cout<<i<<endl;
if(tmp>100) continue;
while(tmp<=100){
vis[tmp]=true;
tmp+=i;
}
}
}
}
int main(){
int n;
get();
scanf("%d",&n);
int res=0,ans=0;
for(int i=1;i<=tot;i++){
int pp=0;
for(int j=que[i];j<=n;j+=que[i]){
int tmp=j;
while(!(tmp%que[i])){
pp++;
tmp/=que[i];
}
}
//cout<<pp<<' '<<i<<endl;
sum[i]=pp;
/*if(que[i]>=5){
if(que[i]*4<=n) ans++,res++;
else if(que[i]*2<=n) ans++;
}
else if(que[i]<5){
if(que[i]*que[i]<=n) ans++,res++;
else if(que[i]*2<=n) ans++;
}*/
}
int a=0,b=0,c=0,d=0,p=0;
//cout<<res<<' '<<ans<<endl;
for(int i=1;i<=tot;i++){
if(sum[i]>=74) p++;
if(sum[i]>=24) a++;
if(sum[i]>=14) b++;
if(sum[i]>=4) c++;
if(sum[i]>=2) d++;
}
//cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
int ANS=a*(d-1);
ANS+=b*(c-1);
ANS+=((c-1)*c/2)*(d-2);
ANS+=p;
printf("%d\n",ANS);
return 0;
}