AtCoder Beginner Contest 114_D

题意描述:

在不超过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 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 <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;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值