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. Ajax请求过程中显示“进度”的简单实现

    Ajax在Web应用中使用得越来越频繁.在进行Ajax调用过程中一般都具有这样的做法:显示一个GIF图片动画表明后台正在工作,同时阻止用户操作本页面(比如Ajax请求通过某个按钮触发,用户不能频繁点击 ...

  2. redis 安装注意事项

    redis安装 1.redis 安装 官网地址:http://redis.io/download $ wget http://download.redis.io/releases/redis-3.0. ...

  3. 【IT历史】SP和CP

    1.什么是SP?SP是英文Service Provider的缩写,中文翻译为服务提供商,通常是指在移动网内运营增值业务的社会合作单位.它们建立与移动网络建立相连的服务平台,为手机用户提供一系列信息服务 ...

  4. windows store app search contract

    代码如下: html: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> ...

  5. 史上最全github使用方法:github入门到精通--备用

    [初识Github] 首先让我们大家一起喊一句“Hello Github”.YEAH!就是这样. Git是一个分布式的版本控制系统,最初由Linus Torvalds编写,用作Linux内核代码的管理 ...

  6. bat写的自动部署脚本

    windows7的机器上重启服务需要关闭UAC ::编译部署项目 echo off echo 1. GatewayAdaptor echo 2. LogicService echo 3. Messag ...

  7. ctf总结

    在过去的一个学期中,草人在西普学院还有一些其他安全夺旗网站上刷了一些题,草人我是菜鸟一个,刚开始很是苦恼,所以经历过以后希望将之分享给一起学习安全的同学,目的呢是希望以后学习的人能尽快理清学习思路,进 ...

  8. Html中如何让超链接a、图片img居中

    一.问题来源 修改博客页面时,突然想到 二.解决办法 2.1原来办法 在img和a中加入align="center",发现不行 2.2百度答案 <div align=&quo ...

  9. matlab怎么同时显示imshow 两幅图片

    matlab怎么同时显示imshow 两幅图片 matlab怎么同时显示imshow 两幅图片 方法一:subplot()函数 subplot(2,1,1); subplot(2,1,2); 分上下或 ...

  10. 解决win8 plsql无法登录

    今天安装完oracle客户端,然后打开 plsql 之后,就一个提示框,提示没有登录,后来解决方法如下: 在plsql的图标上点右键,以管理员身份运行,即可! 如果不想一直点右键执行,就图标上点右键- ...