当前位置:网站首页>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;
}
边栏推荐
- Arthas debugging problem determination Toolkit
- 2022-2028 global ultra high purity electrolytic iron powder industry research and trend analysis report
- Techo youth 2022 academic year college open class: behind the live broadcast of Lianmai, explore how to apply audio and video technology
- Redis - sentinel mode
- New trend of embedded software development: Devops
- Explain kubernetes backup and recovery tools velero | learn more about carina series phase III
- Redis - how to understand publishing and subscribing
- composer
- Why should VR panoramic shooting join us? Leverage resources to achieve win-win results
- Development of wireless U-shaped ultrasonic electric toothbrush
猜你喜欢
Development of wireless U-shaped ultrasonic electric toothbrush
Shell multitasking to download video at the same time
2022-2028 global rotary transmission system industry research and trend analysis report
Vmware16 installing win11 virtual machine (the most complete step + stepping on the pit)
1. crawler's beautifulsoup parsing library & online parsing image verification code
Fh6908a negative pole turn off synchronous rectification analog low voltage drop diode control IC chip tsot23-6 ultra low power rectifier 1W power consumption < 100ua static replacement mp6908
206 page Shanghai BIM Technology Application and development report 2021
VR panorama adds contrast function to make the display of differentiation effect more intuitive!
Redis - how to understand publishing and subscribing
Which is better, server rental or hosting services in the United States?
随机推荐
How to edit special effects in VR panorama? How to display detailed functions?
shell 同时执行多任务下载视频
Is it safe to open a stock account of Huatai Securities online?
In depth understanding of jetpack compose kernel: slottable system
ABAQUS 2022 latest edition - perfect realistic simulation solution
1175. Disposition des nombres premiers / échange de doigts II 104. Nombre de permutations
需求评审,测试人员应该发挥怎样的价值?两分钟让你不再懵逼
Techo youth 2022 academic year college open class: behind the live broadcast of Lianmai, explore how to apply audio and video technology
How to distinguish between platform security and online hype? What are the stop loss techniques for online speculation?
leetcode 474. Ones and zeroes (medium)
2022-2028 global 3D printing ASA consumables industry research and trend analysis report
异步过渡方案—Generator
Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
2022-2028 global ultra high purity electrolytic iron sheet industry research and trend analysis report
2022-2028 global herbal diet tea industry research and trend analysis report
Dell r720 server installation network card Broadcom 5720 driver
2022-06-30:以下golang代码输出什么?A:0;B:2;C:运行错误。 package main import “fmt“ func main()
DNS server setup, forwarding, master-slave configuration
1175. 質數排列 / 劍指 Offer II 104. 排列的數目
2022-06-30: what does the following golang code output? A:0; B:2; C: Running error. package main import “fmt“ func main()