博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Fear Factoring Gym - 101652P(除法分块)
阅读量:4701 次
发布时间:2019-06-09

本文共 638 字,大约阅读时间需要 2 分钟。

转换成1到n的约数和

写一下
F(1) = {1};
F(2) = {1, 2};
F(3) = {1, 3};
F(4) = {1, 2, 4};
F(5) = {1, 5};
F(6) = {1, 2, 3, 6};
所以就是在求
(n/1)* 1 + (n/2)2+(n/3)3+(n/4)4+…+(n/n)n
代码里有注释

#include
#define int unsigned long longconst int maxn=1e5+10;const int mod=1e9+7;int n;ll cal(int n){ int ans=0; for(int i=1,j;i<=n;i=j+1)//枚举因子 { j=n/(n/i); //j是与i出现次数相同的最大因子 ans+=(i+j)*(j-i+1)*(n/i)/2; //i+j 首项加末项 j-i+1项数 n/i出现的次数 } return ans;}#undef intint main(){#define int unsigned long long int a,b; while(cin>>a>>b) { cout<
<

转载于:https://www.cnblogs.com/minun/p/11474875.html

你可能感兴趣的文章
P2709 小B的询问
查看>>
PHP echo 和 print 语句
查看>>
第一讲 一个简单的Qt程序分析
查看>>
Centos 6.5下的OPENJDK卸载和SUN的JDK安装、环境变量配置
查看>>
poj 1979 Red and Black(dfs)
查看>>
【.Net基础03】HttpWebRequest模拟浏览器登陆
查看>>
zTree async 动态参数处理
查看>>
Oracle学习之常见错误整理
查看>>
数据库插入数据乱码问题
查看>>
altium annotate 选项设置 complete existing packages
查看>>
【模式识别与机器学习】——SVM举例
查看>>
【转】IT名企面试:微软笔试题(1)
查看>>
IO流入门-第十章-DataInputStream_DataOutputStream
查看>>
DRF的分页
查看>>
Mysql 模糊匹配(字符串str中是否包含子字符串substr)
查看>>
python:open/文件操作
查看>>
流程控制 Day06
查看>>
Linux下安装Tomcat
查看>>
windows live writer 2012 0x80070643
查看>>
tomcat 和MySQL的安装
查看>>