当前位置:网站首页>Number theory - division and blocking
Number theory - division and blocking
2022-06-29 22:34:00 【sophilex】
I haven't touched number theory for a long time , It's completely rusty .
Made a few number theory problems to sum up .
Carelessness :
seek
Ideas :
Vaguely remember which game did the original question , It's done, too , But now I'm still a little confused ...
Let's convert the formula first

So the whole equation is a little bit like .
Next for each l Find the corresponding r
Make
,
r=max(i),i*t<=n;
obtain :
r=k/t;
This is for every one l Corresponding r, about
Inside
,i In a continuous interval is a sequence of equal difference numbers , Then set the formula directly .
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx *max_element
const ll N=2e5+10;
ll n,k,r;
int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>n>>k;
ll ans=n*k;
for(int l=1;l<=n;l=r+1)
{
ll t=k/l;
if(t!=0) r=min(k/t,n);
else r=n;
ans-=t*(r-l+1)*(l+r)/2;
}
cout<<ans<<endl;
return 0;
}Although it is a provincial election -, But the code is really short .
Carelessness :
Ideas :
First , This
Is o
, That is, the well-known function of finding the divisor of numbers , let me put it another way , here
, among .
You might as well make a conversion , Instead, enumerate first d, be
,
To this step , requirement f(x) That's easy .
Last , because i It's from l To r, that
, In this case, write a function .
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=998244353;
ll a,b;
ll f(ll x)
{
ll ans=0;
ll l,r;
for(ll l=1;l<=x;l=r+1)
{
r=x/(x/l);
ans=(ans+(x/l)*(r-l+1)%mod)%mod;
}
return ans%mod;
}
int main()
{
cin>>a>>b;
cout<<(f(b)-f(a-1)+mod)%mod<<endl;
return 0;
}There are a lot of points , But when I think of it, it's very stiff .
Carelessness :
Ideas :
There is a limitation here i!=j, So we might as well convert the formula .
among 
This is what we discussed in the first question , That should be easy to handle .
Then there's the back , If it unfolds :


The first item here goes without saying , The second and third items are actually the same as those discussed above It's one thing , Just add a constant .
So the last item ,
, The difference from the previous one is i The number of times increased by one , But if you copy the previous ideas , Find the sum of the arithmetic sequence ,
, So this one has been solved , So that's the whole topic ok 了 .
I also want to say a pit , The modular number in the title is not a prime number ...
Blame me for being stupid ,998244353,1e9+7 See more , Everything looks like prime numbers
So the inverse here has to be solved in advance , You can't use a fast power .
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=19940417;
const ll inv2=9970209;
const ll inv6=3323403;
#define endl '\n'
ll n,m;
ll sd(ll x)
{
return x*(x+1)%mod*(2*x+1)%mod*inv6%mod;
}
ll sdd(ll x)
{
return x*(x+1)%mod*inv2%mod;
}
ll f(ll n)// seek sum(n-(n/i)*i)
{
ll sum=n*n%mod;
//cout<<sum<<endl;
for(ll l=1,r;l<=n;l=r+1)
{
ll t=n/l;
r=n/t;
sum=(sum-t*(sdd(r)-sdd(l-1)+mod)%mod+mod)%mod;
//cout<<sum<<endl;
}
return sum;
}
int main()
{
cin>>n>>m;
//cout<<sdd(4)<<' '<<sdd(3)<<endl;
//cout<<f(n)<<" "<<f(m)<<endl;
ll sum=0,ans=0;
sum=(sum+f(n))%mod;
sum=(sum*f(m))%mod;
ans=sum;sum=0;
for(ll l=1,r;l<=min(n,m);l=r+1)
{
r=min(n/(n/l),m/(m/l));
sum+=(r-l+1+mod)%mod*n%mod*m%mod;
sum-=(r-l+1+mod)%mod*(l+r)%mod*((n/l)*m%mod+(m/l)*n%mod)%mod*inv2%mod;
sum+=(sd(r)-sd(l-1)+mod)%mod*(n/l)%mod*(m/l)%mod;
sum=(sum+mod)%mod;
}
cout<<(ans-sum+mod)%mod<<endl;
return 0;
}That's about it first , New questions may be added later
边栏推荐
- 论文浅尝 | KR-GCN: 知识感知推理的可解释推荐系统
- Build a short video platform, fade in and fade out, and support left sliding and right pulley to broadcast pictures
- 分析安装包LNMP中的apache.sh脚本
- 软件快速交付真的需要以安全为代价吗?
- 关于深度学习的概念理解(笔记)
- Huawei cloud AOM version 2.0 release
- 26 years old, 0 basic career change software test, from 3K to 16K monthly salary, a super complete learning guide compiled by me
- Spark集群安装
- A mysql IBD file is too large processing record
- 从第三次技术革命看企业应用三大开发趋势
猜你喜欢

math_基本初等函数图型(幂函数/指数/对数/三角/反三角)

Problem solving metauniverse, multi communication scheme in online games

合宙AIR32F103CBT6开发板上手报告

交友平台小程序制作开发代码分享

Unicom warehousing | all Unicom companies that need to sell their products need to enter the general warehouse first

Qt5.14.2 error connecting to the MySQL database of Ubuntu 20.04

math_ Basic elementary function graph (power function / exponent / logarithm / trigonometry / inverse trigonometry)

从零实现深度学习框架——LSTM从理论到实战【理论】

读书郎上市背后隐忧:业绩下滑明显,市场地位较靠后,竞争力存疑

为什么要同时重写hashcode和equals方法之简单理解
随机推荐
每日刷题记录 (八)
把数组排成最小的数_数组中的逆序对(归并统计法)_数字在升序数组中出现的次数_丑数(剑指offer)
Summary of basic concepts of moosefs
Low code, end-to-end, one hour to build IOT sample scenarios, and the sound network released lingfalcon Internet of things cloud platform
从零实现深度学习框架——RNN从理论到实战【实战】
Spark cluster installation
Dynamic planning learning (continuous update)
【无工具搭建PHP8+oracle11g+Windows环境】内网/无网络/Win10/PHP连接oracle数据库实例
leetcode 416. Partition Equal Subset Sum 分割等和子集(中等)
为什么要同时重写hashcode和equals方法之简单理解
低代码、端到端,一小时构建IoT示例场景,声网发布灵隼物联网云平台
稳!上千微服务接入 Zadig 的最佳姿势(Helm Chart 篇)
Optional类的高级使用
工业细节都是钱和时间砸出来的
Underlying principles of file operations (file descriptors and buffers)
细说GaussDB(DWS)复杂多样的资源负载管理手段
还天天熬夜加班做报表?其实你根本不懂如何高效做报表
Kubernetes architecture that novices must know
laravel 关联模型 多态关系
Conceptual understanding of deep learning (notes)