大水题,一分钟就做完了。。。直接枚举1~n就行了,然后在n中判断出现多少次。

题干:

Description

Input

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

Output

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

Sample Input

3

Sample Output

5

HINT

Source

代码:

#include<iostream>
#include<cstdio>
#include<cmath>
#include<ctime>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
#define duke(i,a,n) for(ll i = a;i <= n;i++)
#define lv(i,a,n) for(int i = a;i >= n;i--)
#define clean(a) memset(a,0,sizeof(a))
const int INF = << ;
typedef long long ll;
typedef double db;
template <class T>
void read(T &x)
{
char c;
bool op = ;
while(c = getchar(), c < '' || c > '')
if(c == '-') op = ;
x = c - '';
while(c = getchar(), c >= '' && c <= '')
x = x * + c - '';
if(op) x = -x;
}
template <class T>
void write(T x)
{
if(x < ) putchar('-'), x = -x;
if(x >= ) write(x / );
putchar('' + x % );
}
ll n,tot = ;
int main()
{
read(n);
duke(i,,n)
{
tot += n / i;
}
write(tot);
return ;
}

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

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

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

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

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

  3. BZOJ-1968 COMMON 约数研究 数论+奇怪的姿势

    1968: [Ahoi2005]COMMON 约数研究 Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1513 Solved: 1154 [Submit] ...

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

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

  5. BZOJ 1968: [Ahoi2005]COMMON 约数研究(新生必做的水题)

    1968: [Ahoi2005]COMMON 约数研究 Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 2351  Solved: 1797 [Submi ...

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

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

  7. [Ahoi2005]COMMON 约数研究 【欧拉线性筛的应用】

    1968: [Ahoi2005]COMMON 约数研究 Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 2939  Solved: 2169 [Submi ...

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

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

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

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

随机推荐

  1. angualr2之路由与导航(一)

    1. 唯一根模块式组件导航 在唯一根模块式组件导航中,全局只有一个模块,即根模块. 1.1 根模块 在根模块中,需要导入所有组件及其对应的服务,并将组件加入声明,将其对应的服务加入提供商. // ap ...

  2. KVO的使用及底层实现

    1.概念 KVO(Key-Value-Observer)也就是观察者模式,是苹果提供的一套事件通知机制.允许对象监听另一个对象特定属性的改变,并在改变时接收到事件,一般继承自NSObject的对象都默 ...

  3. js 事件冒泡、事件捕获、stopPropagation、preventDefault

    转自:http://www.jb51.net/article/42492.htm (1)冒泡型事件:事件按照从最特定的事件目标到最不特定的事件目标(document对象)的顺序触发. IE 5.5: ...

  4. SAP computer之RAM

    RAM The RAM is a 16 X 8 static TTL RAM. We can program the RAM by means of the address and data swit ...

  5. JAVA;使用java.awt.Image的不稳定性

    在使用awt的image时候,不是能时时获取到图像的宽和高, GetWidth()函数偶尔得到的值为-1,暂时没有找到解决方法. 代码: public class picture extends JF ...

  6. 【C++】四种排序算法的时间比较

    四种排序算法的时间比较 [注]clock函数对输入(用户输入)元素N排序的计时 #include<iostream> #include<time.h> using namesp ...

  7. 构造函数+原型的js混合模式

    function Parent(){ this.name = "李小龙"; this.age = "30"; };Parent.prototype.lev=fu ...

  8. matlab学习下拉菜单

    用matlab添加listbox控件 修改string和value值,value为几就对应第几行字符串 添加button按钮,将string值改为“选择x轴参数”,字体大小为10 再添加一个按钮,将s ...

  9. 解决postman https请求无返回数据的问题

    1.点击右上角的扳手图标 2.点击settings 3.点击general 4.把 ssl certificate verification这项点击关闭

  10. Pyhton高级-Socket

    1,UDP实现收发数据 import socket def send_msg(udp_socket): """获取键盘数据,并将其发送给对方""&qu ...