• 优秀数


    题目描述:

    小马曾经说过,万物有优秀与猥琐之分。

    他想要你帮忙确定一个数是否优秀。

    小马认为,一个数优秀,当且仅当它有不超过 4 个因子。

    求小于等于n的优秀的数的个数。

    输入格式:

    一个正整数 n

    输出格式:

    一个数表示答案

    样例输入1:

    5

    样例输出1:

    5

    约定:

    1<=n<=100000

    #include<bits/stdc++.h>
    using namespace std;
    int fzm(int m){
        int t=0;
        for(int i=1;i<=m;i++){
            if(m%i==0){
                t++;
            }
        }
        return t;
    }
    int main(){
        int n;
        cin>>n;
        int t=0;
        int a[n+1]={0};
        for(int i=1;i<=n;i++){
            int k=0;
            k=fzm(i);
            if(k<=4){
                a[i]=1;
            }
        }
        for(int i=1;i<=n;i++){
            t+=a[i];
        }
        cout<<t<<endl;
    }
  • 相关阅读:
    cz_health_day07
    cz_health_day06
    mysql索引底层原理
    cz_health_day05
    redis无法获取连接原因分析
    cz_health_day04
    cz_health_day03
    cz_health_day02
    cz_health_day01
    Spring学习
  • 原文地址:https://www.cnblogs.com/fangzm/p/13660718.html
Copyright © 2020-2023  润新知