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. 实时监听input输入框value值的变化

    1.js 的 oninput & onpropertychange JS中的 oninput 事件在 IE9 以下版本不支持,需要使用 IE 特有的 onpropertychange 事件替代 ...

  2. AVAudioRecorder 录制音频

    AVFoundation 中使用AVAudioRecorder 类添加音频录制功能是非常简单的, AVAudioRecorder构建与Audio Queue Services之上是一个功能强大且代码简 ...

  3. NOSQL之【Redis学习:配置说明】

    # yes:后台运行:no:不是后台运行(老版本默认) daemonize yes # redis的进程文件 pidfile /var/run/redis.pid # 端口 port # bind_a ...

  4. 详解MySQL中EXPLAIN解释命令(转)

    explain显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. 使用方法,在select语句前加上explain就可以了: 如: expla ...

  5. 响应式布局中重要的meta标签设置.适用于手机浏览器兼容性设置

    <!-- #手机浏览器兼容性设置 -->    <meta content="application/xhtml+xml;charset=UTF-8" http- ...

  6. 创建Mysql

    CREATE DATABASE IF NOT EXISTS yiya DEFAULT CHARSET utf8 COLLATE utf8_general_ci;

  7. jquery set selected for select element

    //1$("#Provider_" + counter + " option[value=" + FormData.ID + "]").at ...

  8. Apple 如何知道你使用了私有API

    大约有三种方式 otool -L这个工具可以清晰的列出你链接所有的库 像IO.Kit是不允许使用的 nm -u 这个工具可以清晰的列出你所有链接符号如 C方法 OC方法 检查所有Selecter的字符 ...

  9. 原生 JavaScript 图片裁剪效果

    图片裁剪程序效果如下,可鼠标操作.   拖动左边小方框时在右侧实时显示对应的裁剪图片,同时左侧的拖动框里图片完全显示,拖动框外部图片模糊显示.8个控制点可以对显示区域大小进行控制. HTML 和 CS ...

  10. 再eclipse的javaweb项目中添加JQuery文件时jquery-2.1.4.min.js报错

    解决方法: eclipse导入jquery包后报错,下面有个不错的解决方法,需要的朋友可以参考下 eclipse导入jquery包后报错,处理步骤如下: 1.打开项目.project文件,去掉如下内容 ...