link : https://loj.ac/problem/125

分块calc即可。

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int ha=998244353;
int n,ans[3]; inline int add(int x,int y){
x+=y;
return x>=ha?x-ha:x;
} inline int ci0(int x){
return x%ha;
} inline int ci1(int x){
return (x*(ll)(x+1)>>1)%ha;
} inline int ci2(int x){
ll u=x*(ll)(x+1)>>1;
if(!(u%3)) return u/3%ha*(ll)(2*x+1)%ha;
else return u%ha*(ll)((2*x+1)/3)%ha;
} inline int calc(){
int an[3];
an[0]=an[1]=an[2]=0;
for(int i=1,j,now;i<=n;i=j+1){
now=n/i,j=n/now;
an[0]=add(an[0],add(ci0(j),ha-ci0(i-1))*(ll)now%ha);
an[1]=add(an[1],add(ci1(j),ha-ci1(i-1))*(ll)now%ha);
an[2]=add(an[2],add(ci2(j),ha-ci2(i-1))*(ll)now%ha);
} return (an[0]*5ll+an[1]*3ll+an[2]*2ll)%ha;
} int main(){
scanf("%d",&n);
printf("%d\n",calc());
return 0;
}

  

Loj #125. 除数函数求和(2)的更多相关文章

  1. LOJ #124. 除数函数求和 1

    题目描述 $\sigma_k(n) = \sum_{d | n} d ^ k$​ 求 $\sum_{i=1}^n\sigma_k(i)$ 的值对 109 取模的结果. 输入格式 第一行两个正整数 n, ...

  2. Loj #124. 除数函数求和

    链接:https://loj.ac/problem/124 就是筛一下积性函数. #include<bits/stdc++.h> #define ll long long #define ...

  3. loj124 除数函数求和 1

    loj124 除数函数求和 1 https://loj.ac/problem/124 $\sum_{i=1}^n(\sum_{d|i}d^k)=\sum_{i=1}^n(i^k*{\lfloor}{\ ...

  4. LiberOJ #124. 除数函数求和 【整除分块】

    一.题目 #124. 除数函数求和 二.分析 比较好的一题,首先我们要对题目和样例进行分析,明白题目的意思. 由于对于每一个$d$,它所能整除的数其实都是定的,且数量是$ \lfloor \frac{ ...

  5. loj125 除数函数求和 2

    https://loj.ac/problem/125 $原式=2\sum_{i=1}^n(i^2*{\lfloor}{\frac{n}{i}}{\rfloor})+3\sum_{i=1}^n(i*{\ ...

  6. C语言编程题

    1.将整形a的第m位赋值到整形b的第n位 int fun4(int a, int m, int b, int n) { a = (a>>m) & ;//将a的第m位取出,为1或0, ...

  7. 【LOJ#572】Misaka Network 与求和(莫比乌斯反演,杜教筛,min_25筛)

    [LOJ#572]Misaka Network 与求和(莫比乌斯反演,杜教筛,min_25筛) 题面 LOJ \[ans=\sum_{i=1}^n\sum_{j=1}^n f(gcd(i,j))^k\ ...

  8. Loj #528. 「LibreOJ β Round #4」求和 (莫比乌斯反演)

    题目链接:https://loj.ac/problem/528 题目:给定两个正整数N,M,你需要计算ΣΣu(gcd(i,j))^2 mod 998244353 ,其中i属于[1,N],j属于[1,M ...

  9. LOJ #2058「TJOI / HEOI2016」求和

    不错的推柿子题 LOJ #2058 题意:求$\sum\limits_{i=0}^n\sum\limits_{j=0}^nS(i,j)·2^j·j!$其中$ S(n,m)$是第二类斯特林数 $ Sol ...

随机推荐

  1. python3爬取”理财大视野”中的股票,并分别写入txt、excel和mysql

    需求:爬取“理财大视野”网站的排名.代码.名称.市净率.市盈率等信息,并分别写入txt.excel和mysql 环境:python3.6.5 网站:http://www.dashiyetouzi.co ...

  2. octave-basic

    在coursera上斯坦福的machine learning,lecturer极力推荐开源的编程环境Octave入手,所以我也下载了来试一试吧== 参考链接:http://www.linuxdiyf. ...

  3. poj-1011 sticks(搜索题)

    George took sticks of the same length and cut them randomly until all parts became at most 50 units ...

  4. Linux 关于SELinux的命令及使用

    1. 模式的设置 : 修改/etc/selinux/config文件中的SELINUX=”" 的值 ,然后重启.enforcing:强制模式,只要selinux不允许,就无法执行 permi ...

  5. 库函数的使用:POJ1488-TEX Quotes(getline()的使用)

    TEX Quotes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9385 Description TEX is a type ...

  6. 实践自己的WebSite______流水

    尝试从头至尾搭建一个MVC的网站,主要以流水的方式进行进度和记录,而不讨论技术的部分. 1,在Controller下创建两个文件夹,分别为sys和Business,分别对应于系统功能和业务逻辑.比如登 ...

  7. Huawei比赛数据分析

    如何评价2018年华为软件精英挑战赛赛题? https://www.zhihu.com/question/268448695 1.时间与时间戳之间的转换 https://blog.csdn.net/g ...

  8. python常用方法总结

    1.os模块的路径拼接: import os now_path=os.path.abspath(__file__)#当前运行文件的路径 print(now_path) uppeer_path=os.p ...

  9. P2564 生日礼物

    生日礼物 洛谷链接 题目描述: 在一段彩带上有不同颜色的彩珠,求出包含所有颜色彩珠的最短彩带长度. 思路: 我们可以把按彩珠的位置把所有彩珠排一下序,然后从1开始遍历这些彩珠,并记录出现过的颜色数目, ...

  10. POJ 1323 Game Prediction

    Game Prediction Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8956   Accepted: 4269 D ...