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. [译]The Python Tutorial#5. Data Structures

    [译]The Python Tutorial#Data Structures 5.1 Data Structures 本章节详细介绍之前介绍过的一些内容,并且也会介绍一些新的内容. 5.1 More ...

  2. perl-tips-1

    .pm 应该保存 Perl Module,也就是 Perl 模块.例如 Socket.pm.pl 应该保存 Perl Library,也就是 Perl 库文件.例如 perldb.pl.plx 应该保 ...

  3. MIP启发式算法:遗传算法 (Genetic algorithm)

    *本文主要记录和分享学习到的知识,算不上原创 *参考文献见链接 本文主要讲述启发式算法中的遗传算法.遗传算法也是以local search为核心框架,但在表现形式上和hill climbing, ta ...

  4. Solution: 最近公共祖先·一 [hiho一下 第十三周]

    题目1 : 最近公共祖先·一 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho最近发现了一个神奇的网站!虽然还不够像58同城那样神奇,但这个网站仍然让小Ho乐在其中 ...

  5. sql 查询数据库中每个表的大小

    For example: exec sp_MSForEachTable @precommand=N'create table temp(name sysname,rows bigint,reserve ...

  6. [python学习篇] uiautomator xiaocong

    Skip to content     This repository Pull requests Issues Marketplace Gist   Sign out       Watch103 ...

  7. RHEL 7.3修改网卡命名规则为ethX

    RHEL 7网卡默认命名规则:以太网卡(Ethernet)为enX,无线网卡(WLAN)为wlX,修改网卡命名规则为ethX如下: 1.修改/etc/sysconfig/grub文件,添加net.if ...

  8. ora-08104 该索引对象 159639 正在被联机建立或重建

    SSH远程连接数据库创建索引,网络中断后,删除索引信息报ora-08104 解决方法: 使用ONLINE_INDEX_CLEAN清除索引痕迹 在sys用户下执行 SQL> conn /as sy ...

  9. Welcome-to-Swift-01基础部分

    Swift 是 iOS 和 OS X 应用开发的一门新语言.然而,如果你有 C 或者 Objective-C 开发经验的话,你会发现 Swift 的很多内容都是你熟悉的. Swift 的类型是在 C ...

  10. spring分布式事务控制

    应用场景问题描述解决方法多数据源配置单元测试第一种方法:最大努力一次提交模式第二种方法:最大努力一次提交模式 但使用ChainedTransactionManagerChainedTransactio ...