Description

Input

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

Output

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

Sample Input

3

Sample Output

5

HINT

Source

 
正解:数学
解题报告:
  讨论每个因子的贡献就可以了。
 
  1. //It is made by jump~
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <cstring>
  5. #include <cstdio>
  6. #include <cmath>
  7. #include <algorithm>
  8. #include <ctime>
  9. #include <vector>
  10. #include <queue>
  11. #include <map>
  12. #include <set>
  13. using namespace std;
  14. typedef long long LL;
  15. int n,ans;
  16.  
  17. inline int getint()
  18. {
  19. int w=,q=; char c=getchar();
  20. while((c<'' || c>'') && c!='-') c=getchar(); if(c=='-') q=,c=getchar();
  21. while (c>='' && c<='') w=w*+c-'', c=getchar(); return q ? -w : w;
  22. }
  23.  
  24. inline void work(){
  25. n=getint(); for(int i=;i<=n;i++) ans+=n/i; printf("%d",ans);
  26. }
  27.  
  28. int main()
  29. {
  30. work();
  31. return ;
  32. }

BZOJ1968 [Ahoi2005]COMMON 约数研究的更多相关文章

  1. bzoj千题计划170:bzoj1968: [Ahoi2005]COMMON 约数研究

    http://www.lydsy.com/JudgeOnline/problem.php?id=1968 换个角度 一个数可以成为几个数的约数 #include<cstdio> #incl ...

  2. BZOJ1968 [Ahoi2005]COMMON 约数研究 数论

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1968 题意概括 求 ΣF(i)   (1<=i<=n)N<=1000000 F( ...

  3. 【数论】bzoj1968 [Ahoi2005]COMMON 约数研究

    对于i属于[1,n],i只能成为[1,n]中n/i个数的约数,易证. #include<stdio.h> int n,i; long long ans; int main() { scan ...

  4. [日常摸鱼]bzoj1968 [Ahoi2005]COMMON 约数研究

    题意:记$f(n)$为$n$的约数个数,求$\sum_{i=1}^n f(i)$,$n \leq 10^6$. 我也不知道为什么我要来做这个- 直接枚举每个数会是哪些数的约数-复杂度$O(n log ...

  5. bzoj1968: [Ahoi2005]COMMON 约数研究(数论)

    计算每一个数的贡献就好了..O(N) n/i只有2*sqrtn个取值于是可以优化到O(sqrtn) #include<bits/stdc++.h> #define ll long long ...

  6. [BZOJ1968][AHOI2005]COMMON约数研究 数学

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1968 直接计算每个因子的贡献就可以了. $Ans=\sum_{i=1}^n[\frac{n ...

  7. BZOJ1968: [Ahoi2005]COMMON 约数研究 线性筛

    按照积性函数的定义筛一下这个积性函数即可. #include <cstdio> #include <algorithm> #define N 1000004 #define s ...

  8. BZOJ 1968: [Ahoi2005]COMMON 约数研究

    1968: [Ahoi2005]COMMON 约数研究 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 2032  Solved: 1537[Submit] ...

  9. BZOJ 1968: [Ahoi2005]COMMON 约数研究 水题

    1968: [Ahoi2005]COMMON 约数研究 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeO ...

随机推荐

  1. SVN版本回退

    [SVN版本回退] 在Windows里,先打开Log面板,根据想要回退的内容,然后选择revert to this revision或者revert changes from this revisio ...

  2. java 21 - 6 字符缓冲流的特殊方法以及该方法高效复制文件

    字符缓冲流的特殊方法: A.BufferedWriter: public void newLine():根据系统来决定换行符 private static void write() throws IO ...

  3. sqlzoo.net刷题2

    Find the largest country (by area) in each continent, show the continent, thename and the area: 找到每个 ...

  4. 九、Foundation框架中的NSString常用方法

    一.NSString的创建 方式1创建常量字符串 NSString *st = @"this is string!"; //这种方式创建的字符串不需要释放 方式2创建空字符串,给予 ...

  5. 15SpringMvc_在业务控制方法中写入模型变量收集参数,且使用@InitBind来解决字符串转日期类型

    之前第12篇文章中提到过在业务控制方法中写入普通变量收集参数的方式,也提到了这种凡方式的弊端(参数很多怎么办),所以这篇文章讲的是在业务控制方法中写入模型变量来收集参数.本文的案例实现的功能是,在注册 ...

  6. MVC4 WebAPI POST数据问题

    api [HttpPost] public string PostAvartos(Test model) { if (model != null) { LoggerHelper.WriteInfo(m ...

  7. [py] 导入模块 reload(sys)

        #!/usr/bin/env python # coding: utf-8 import sys   reload(sys) #<------这个是什么意思 sys.setdefault ...

  8. [py]chr ord

    http://www.xuebuyuan.com/2067536.html 也可以help(ord)

  9. 使用ConfigurationManager类读写配置文件

    使用ConfigurationManager类 读写配置文件app.config,以下为代码: view plaincopy to clipboard print? using System; usi ...

  10. An Introduction to Interactive Programming in Python (Part 1) -- Week 2_3 练习

    Mini-project description - Rock-paper-scissors-lizard-Spock Rock-paper-scissors is a hand game that ...