zoukankan      html  css  js  c++  java
  • bzoj1968 [Ahoi2005]COMMON 约数研究

    1968: [Ahoi2005]COMMON 约数研究

    Time Limit: 1 Sec  Memory Limit: 64 MB

    Description

    Input

    只有一行一个整数 N(0 < N < 1000000)。

    Output

    只有一行输出,为整数M,即f(1)到f(N)的累加和。

    Sample Input

    3

    Sample Output

    5
     
     
     
    Tip:
      这是一道思维题,想到后就会觉得很简单;
      请先思考思考;
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      。
      我们可以知道F[x]=n/x;
      约数中有x的数有n整除x个,我们只要线扫一遍就能得出答案;
     
    Code:
    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    using namespace std;
    int main(){
        long long n,res=0,a,b;
        scanf("%lld",&n);
        for(int i=1;i<=n;i++){
            res+=n/i;
        }
        printf("%lld",res);
    }
      
  • 相关阅读:
    6-stm32 滴答定时器(delay不带中断延时)
    5-stm32 滴答定时器(delay中断延时)
    4- stm32 gpio重映射
    3- stm32 gpio寄存器
    2-stm32 gpio位带
    Linux Command
    DIV+CSS规范命名
    JS事件报错之Cannot set property 'onclick' of null
    创建对象的三种方式
    密码的显示和隐藏
  • 原文地址:https://www.cnblogs.com/WQHui/p/7475736.html
Copyright © 2011-2022 走看看