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);
    }
      
  • 相关阅读:
    ios实现下拉刷新,上拉加载
    ios实现瀑布流
    ios收货地址三级联动选择
    ios仿淘宝管理收货地址demo
    引用传值
    继承小结
    is操作符和as操作符
    抽象类和object类
    重写基类
    派生
  • 原文地址:https://www.cnblogs.com/WQHui/p/7475736.html
Copyright © 2011-2022 走看看