hunnu Sum of f(x)
|
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 |
| Sample Output |
17 |
#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)的更多相关文章
- 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) + ...
- hnnu 11546 Sum of f(x) (求一个数的全部约数和)
代码: #include<cstdio> #include<cstring> #define N 200000 using namespace std; long long f ...
- hunnu-11546--Sum of f(x)
Sum of f(x) Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KB Total submit users: ...
- 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 ...
- hdu 4389 X mod f(x) 数位DP
思路: 每次枚举数字和也就是取模的f(x),这样方便计算. 其他就是基本的数位Dp了. 代码如下: #include<iostream> #include<stdio.h> # ...
- 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 ...
- poj 1564 Sum It Up (DFS+ 去重+排序)
http://poj.org/problem?id=1564 该题运用DFS但是要注意去重,不能输出重复的答案 两种去重方式代码中有标出 第一种if(a[i]!=a[i-1])意思是如果这个数a[i] ...
- 牛客练习赛19 E和F(签到就走系列)托米的饮料+托米搭积木
E题传送门:点我 F题传送门:点我 可爱的小托米得到了n瓶饮料. 但他不小心把开盖的工具弄丢了,所以他只能利用饮料瓶来开盖. 已知第i个瓶子的品牌为ai,且其能打开bi品牌的瓶子. 问有几瓶饮料托米无 ...
- 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号结 ...
随机推荐
- keepalived+haproxy-部署高可用负载均衡
环境: 准备两台机子,安装haproxy及keepalive都一样,只是配置不一样而已. 这里只说明一台机子上安装haproxy及keepalive. ======================== ...
- ubuntu14.04配置lnmp
看到了一片讲解ubuntu下安装lnmp的文章,跟着一步步的来,竟然很顺利的成功了,将文章复制如下,原著勿怪 一.操作步骤 1.安装Nginx sudo apt-get install update ...
- Oracle Database does not provide any supplemental logging, which means that by default LogMiner is not usable
写在前面,在研究Oracle logmnr 的时候看到 http://www.askmaclean.com/archives/dbms_logmnr-unsupported-sqlredo.html ...
- opengl打开本地bmp图片绘制
注意bmp图片的格式问题,32位ARGB 或者24位RGB.你所采用的素材一定要注意是多少位的就用多少位的.否则会显示错误的图片或者其他什么的错误. 代码如下 32位版本 #include < ...
- Ubuntu Vim YouCompleteMe 安装
0. 必要工具安装 sudo apt-get install build-essential cmake 1. 安装 vundle mkdir ~/.vim/bundle git clone http ...
- mysql查看表结构命令
mysql查看表结构命令 mysql查看表结构命令,如下: desc 表名;show columns from 表名;describe 表名;show create table 表名; use inf ...
- 【Http】Http权威指南
God Is Coder 2012-10-17 22:25 阅读:77 评论:0 <http权威指南>阅读笔记(十二) God Is Coder 2012-10-17 22:04 阅读 ...
- 蜗牛历险记(二) Web框架(中)
上篇简单介绍了框架所使用的Autofac,采用Autofac提供的Ioc管理整个Web项目中所有对象的生命周期,实现框架面向接口编程.接下来介绍框架的日志系统. 一.介绍之前 框架日志是否有存在的必要 ...
- TOKEN+签名验证
TOKEN+签名验证 首先问大家一个问题,你在写开放的API接口时是如何保证数据的安全性的?先来看看有哪些安全性问题在开放的api接口中,我们通过http Post或者Get方式请求服务器的时候,会面 ...
- Asp.Net MVC ajax调用 .net 类库问题
如果你还在为 ajax 调用 .net 类库还束手无策的话,相信这篇博客将帮助你解决这个世纪问题! 因为Visual Studio 内置了asp.net mvc ,不过当你添加asp.net mvc项 ...