http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11546&courseid=0

Sum of f(x)

Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB
Total submit users: 196, Accepted users: 118
Problem 11546 : No special judgement
Problem description
  令f(x)为x的所有约数之和,x的约数即可以被x整除的数,如f(24)=1+2+3+4+6+8+12+24=60),求 f(l) + f(l + 1) + …… + f(r)

Input
  第一行为一个整数T(T<=100000),表示数据的组数。
接下来T行,每行有两个整数l,r(1 <= l <= r <= 200000)

Output
  对每组数据,输出f(l)+f(l+1)+……+f(r) 的和

Sample Input
2
3 5
10 20
Sample Output
17
270
#include<iostream>
#include<cstring>
#include<cstdio>
#define n 200005
using namespace std;
__int64 f[n],s[n];
int main()
{
int i,j; memset(f,,sizeof(f));
memset(s,,sizeof(s));
for(i=;i<=n;i++)
{
for(j=;i*j<=n;j++)
{
f[i*j]+=i;
}
}
for(i=;i<=n;i++)
{
s[i]=s[i-]+f[i];
}
int t,l,r;
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&l,&r);
printf("%I64d\n",s[r]-s[l-]);
}
return ;
}

hunnu Sum of f(x)的更多相关文章

  1. hunnu11546:Sum of f(x)

    Problem description   令f(x)为x的全部约数之和,x的约数即能够被x整除的数.如f(24)=1+2+3+4+6+8+12+24=60),求 f(l) + f(l + 1) + ...

  2. hnnu 11546 Sum of f(x) (求一个数的全部约数和)

    代码: #include<cstdio> #include<cstring> #define N 200000 using namespace std; long long f ...

  3. hunnu-11546--Sum of f(x)

    Sum of f(x) Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB Total submit users:  ...

  4. three Sum

    Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...

  5. hdu 4389 X mod f(x) 数位DP

    思路: 每次枚举数字和也就是取模的f(x),这样方便计算. 其他就是基本的数位Dp了. 代码如下: #include<iostream> #include<stdio.h> # ...

  6. geeksforgeeks@ Find sum of different corresponding bits for all pairs (Bit manipulation)

    http://www.practice.geeksforgeeks.org/problem-page.php?pid=387 Find sum of different corresponding b ...

  7. poj 1564 Sum It Up (DFS+ 去重+排序)

    http://poj.org/problem?id=1564 该题运用DFS但是要注意去重,不能输出重复的答案 两种去重方式代码中有标出 第一种if(a[i]!=a[i-1])意思是如果这个数a[i] ...

  8. 牛客练习赛19 E和F(签到就走系列)托米的饮料+托米搭积木

    E题传送门:点我 F题传送门:点我 可爱的小托米得到了n瓶饮料. 但他不小心把开盖的工具弄丢了,所以他只能利用饮料瓶来开盖. 已知第i个瓶子的品牌为ai,且其能打开bi品牌的瓶子. 问有几瓶饮料托米无 ...

  9. Codeforces Round #530 (Div. 2):D. Sum in the tree (题解)

    D. Sum in the tree 题目链接:https://codeforces.com/contest/1099/problem/D 题意: 给出一棵树,以及每个点的si,这里的si代表从i号结 ...

随机推荐

  1. C# WinForm实现控件拖动实例介绍

    主要是设计控件的MouseDown.MouseLeave.MouseMove事件.一步步来吧:1.定义一个枚举类型,描述光标状态 private enum EnumMousePointPosition ...

  2. Missra开源前端框架

    Missra开源前端框架,官方网址:http://framework.missra.com

  3. php用户验证代码的简单例子

    发布:sunday01   来源:net     [大 中 小] 分享一个简单的php用户验证代码,适合初学的朋友参考,主要学习$_post传递数据及isset检测变量的方法. php简单用户验证代码 ...

  4. CSS中Padding的用法

    Padding的英文意思是填充,在CSS中则是设置内边距属性. padding不允许使用负值 1. 四个参数时: padding: 10px,20px,30px,40px; 上边距:10px 右边距: ...

  5. 【1】Bootstrap入门引言

    Bootstrap学习者要具备的一些要求: [1]xhtml常用标签的基础知识 [2]xhtml+css布局的基础知识 [3]html5+css3的基础知识 ===================== ...

  6. How to open .ccproj in VS2010?

    Q: How to open .ccproj projects types in VS2010, ccproj file type is a Cloud project i suppose. Plea ...

  7. lua中的时间函数

    -- 获取当前的格林尼治时间print(os.time())-- 获取当前时间的字符串表示,形如:11/28/08 10:28:37print(os.date())-- 获取当前日期的字符串表示,形如 ...

  8. dos下的edit命令使用详解

    dos下的edit命令使用详解 来源:网络 作者:未知 edit命令是一个简单的编辑软件,我们经常用它来编辑一些程序和批处理文件. 比如,我想在c盘根目录下编辑一个简单的批处理文件,要求无论当前盘和当 ...

  9. Seay工具分享

    百度网盘:http://pan.baidu.com/share/home?uk=4045637737&view=share#category/type=0

  10. [Gauss]POJ3185 The Water Bowls

    题意:反正就是要给的一串01的变成全0 能影响自己和左右 最少需要几步 01方程组 异或解 ][]; // 增广矩阵 ]; // 解 ]; // 标记是否为自由未知量 int n; void debu ...