当前位置:网站首页>Yboj mesh sequence [Lagrange interpolation]
Yboj mesh sequence [Lagrange interpolation]
2022-07-01 00:16:00 【QuantAsk】
On the subject
The main idea of the topic
There is one n × m n\times m n×m The grid of , Fill it in [ 1 , k ] [1,k] [1,k] The number of , Define two lengths as n n n Sequence a i , b i a_i,b_i ai,bi Represent each line separately / The maximum value of each column .
Ask how many different legal a , b a,b a,b Yes .
1 ≤ n , m ≤ 1 0 6 , 1 ≤ k ≤ 1 0 9 1\leq n,m\leq 10^6,1\leq k\leq 10^9 1≤n,m≤106,1≤k≤109
Their thinking
It is not difficult to find legal a , b a,b a,b It is only necessary to satisfy that their maximum values are equal .
Then enumerate the maximum values i i i, The answer is
∑ i = 1 k ( i n − ( i − 1 ) n ) ( i m − ( i − 1 ) m ) \sum_{i=1}^k(i^n-(i-1)^n)(i^m-(i-1)^m) i=1∑k(in−(i−1)n)(im−(i−1)m)
Seeing this formula, I decided that it was a sum of k k k Relevant n + m + 1 n+m+1 n+m+1 Sub polynomial , Again because k k k It's big and n , m n,m n,m Very small direct interpolation .
Time complexity : O ( n log n ) O(n\log n) O(nlogn)( Depending on the n , m n,m n,m At the same level )
code
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const ll N=3e6+10,P=998244353;
ll n,m,k,pwn[N],pwm[N],f[N],inv[N],pre[N],suf[N],ans;
ll power(ll x,ll b){
ll ans=1;
while(b){
if(b&1)ans=ans*x%P;
x=x*x%P;b>>=1;
}
return ans;
}
signed main()
{
freopen("grid.in","r",stdin);
freopen("grid.out","w",stdout);
scanf("%lld%lld%lld",&n,&m,&k);
ll L=n+m+10;
for(ll i=1;i<=L;i++){
pwn[i]=power(i,n);
pwm[i]=power(i,m);
f[i]=(f[i-1]+(pwn[i]-pwn[i-1])*(pwm[i]-pwm[i-1])%P)%P;
}
inv[0]=inv[1]=1;
for(ll i=2;i<N;i++)inv[i]=P-inv[P%i]*(P/i)%P;
for(ll i=1;i<N;i++)inv[i]=inv[i-1]*inv[i]%P;
pre[0]=k;suf[L]=k-L;suf[L+1]=1;
for(ll i=1;i<=L;i++)pre[i]=pre[i-1]*(k-i)%P;
for(ll i=L-1;i>=0;i--)suf[i]=suf[i+1]*(k-i)%P;
for(ll i=0;i<=L;i++){
ll w=f[i]*(i?pre[i-1]:1)%P*suf[i+1]%P;
w=w*inv[i]%P*inv[L-i]%P*(((L-i)&1)?-1:1);
ans=(ans+w)%P;
}
printf("%lld\n",(ans+P)%P);
return 0;
}
边栏推荐
- [leetcode] [SQL] notes
- 206 page Shanghai BIM Technology Application and development report 2021
- File reading and writing for rust file system processing - rust Practice Guide
- Combining online and offline, VR panorama is a good way to transform furniture online!
- Fund customer service
- 五分钟搞懂探索式测试
- 206页上海BIM技术应用与发展报告2021
- 女朋友说:你要搞懂了MySQL三大日志,我就让你嘿嘿嘿!
- Bridge emqx cloud data to AWS IOT through the public network
- Fund clients and sales agencies
猜你喜欢

2022-2028 global electric yacht industry research and trend analysis report

shell 同时执行多任务下载视频
![[designmode] factory pattern](/img/62/9be808b3e1c2139d564caa307fcd30.png)
[designmode] factory pattern

Error 2059 when Navicat connects to MySQL

Redis - cache penetration, cache breakdown, cache avalanche

Development of wireless U-shaped ultrasonic electric toothbrush

2022-2028 global single travel industry research and trend analysis report

Random ball size, random motion collision

2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report

To tell you the truth, ThreadLocal is really not an advanced thing
随机推荐
Why did kubernetes win? The changes in the container circle!
Bridge emqx cloud data to AWS IOT through the public network
Excuse me, does Flink support synchronizing data to sqlserver
2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report
What value should testers play in requirements review? Two minutes will stop you from being stupid
Which is better, server rental or hosting services in the United States?
Dataloader source code_ DataLoader
Is it safe to buy funds on the compass?
206 page Shanghai BIM Technology Application and development report 2021
Prospects of world digitalization and machine intelligence in the next decade
C WinForm program interface optimization example
Don't worry about whether you can be a coder if you don't learn English well. Learn it first
Schéma de transition asynchrone - générateur
MaxPool2d详解--在数组和图像中的应用
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
Error when starting PHP: [pool www] cannot get uid for user '@php_ fpm_ [email protected]’
Reason why wechat payment wxpaypubhelper V3 callback XML is empty
让企业数字化砸锅和IT主管背锅的软件供应链安全风险指北
2022-2028 global electric yacht industry research and trend analysis report
Simple application example of rhai script engine