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号结 ...
随机推荐
- 七牛云覆盖上传 php
使用七牛云过程中遇到了需要上传覆盖的情况,最终解决,分享给大家. 七牛云sdk上传示例中是这样写的 <?php require_once 'path_to_sdk/vendor/autoload ...
- 一台Ubuntu server上安装多实例MySQL
受环境所迫,在一台Ubuntu server上安装多个实例MySQL. 手动安装MySQL 环境:Ubuntu server 11.10 64bit + mysql-5.5.17-linux2.6-x ...
- jquery <li>标签 隔若干行 加空白或者加虚线
$(function () { $('ul li').addClass(function (i) { return i % 6 == 5 ? "ab" : "" ...
- AngularJS(1)随笔
ng-app 指令告诉 AngularJS,<div> 元素是 AngularJS 应用程序 的"所有者". ng-model 指令把输入域的值绑定到应用程序变量 na ...
- php学习日志(1)-php介绍
在学习Php之前,我们要搞懂php是什么.英文全称php: php hypertext preprocessor,即php超文本预处理器.php脚本在服务器上执行,故它是一种服务器编程语言. php文 ...
- JAVA获取当前日期以及将字符串转成指定格式的日期
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ pac ...
- DevExpress VCL 一键安装工具
一键安装工具 DxAutoInstaller-2.1.3 For Devexpress VCL:http://download.csdn.net/detail/wozengcong/8396181 一 ...
- MVC+EF 随笔小计——分部视图(Partial View)及Html.Partial和Html.Action差异
Partial View指可以应用于View中以作为其中一部分的View的片段(类似于之前的user control), 可以像类一样,编写一次, 然后在其他View中被反复使用. 一般放在" ...
- 常用后台frame框架
一般后台框架结构: top:左边显示logo,右边显示模块信息. left:对应模块的菜单信息. content:具体的内容. bottom:版权.时间等一些碎屑信息. Html代码: <htm ...
- unity3d游戏开发——新手引导
GUI实现,如下: 按“G”键开始新手引导 代码如下: using UnityEngine; using System.Collections; public class OkButton : GUI ...