当前位置:网站首页>P5472 [noi2019] douzhudi (expectation, Mathematics)
P5472 [noi2019] douzhudi (expectation, Mathematics)
2022-07-28 11:49:00 【wind__ whisper】
Preface
Why didn't I even type my watch .
too vegetable.
analysis
The shuffle form given by the title doesn't look good , Reasonable guess can find , In fact, this is equivalent to all possible situations with equal probability . And then it won't
You can find out by typing your watch : When tp=1 when ,dp An array is a sequence of arithmetical numbers . When tp=2 when ,dp The difference of an array is an equal difference sequence .
Further speculation : If the original dp An array is i Sub polynomial , Then after the shuffle, or i i i Sub polynomial . However, I can't prove
With this conclusion , Keep maintaining the coefficients of this polynomial that is not more than quadratic .
Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define ok debug("line: %d\n",__LINE__)
inline ll read(){
ll x(0),f(1);char c=getchar();
while(!isdigit(c)) {
if(c=='-')f=-1;c=getchar();}
while(isdigit(c)) {
x=(x<<1)+(x<<3)+c-'0';c=getchar();}
return x*f;
}
bool mem1;
const int N=1e7+100;
const int inf=1e9+100;
const int mod=998244353;
const bool Flag=0;
#define add(x,y) ((((x)+=(y))>=mod)&&((x)-=mod))
inline ll ksm(ll x,ll k){
ll res(1);
while(k){
if(k&1) res=res*x%mod;
x=x*x%mod;
k>>=1;
}
return res;
}
int n,m;
ll a,b,c;
inline ll calc(ll x){
return (x*x%mod*a+b*x+c)%mod;}
bool mem2;
signed main(){
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif
debug("mem=%lf\n",abs(&mem2-&mem1)/1024./1024);
n=read();m=read();int tp=read();
//n=1e7;m=5e5;int tp=2;
a=tp==2;b=tp==1;c=0;
ll niv1=ksm((1ll*n*n-1-3*(n-1))%mod,mod-2);
ll nin=ksm(n,mod-2),nin1=ksm(n-1,mod-2);
for(int i=1;i<=m;i++){
int A=read();
//int A=rand()%n+1;
ll f1=calc(1),f2=calc(2),fa=calc(A),fa1=calc(A+1),fa2=calc(A+2),fn=calc(n);
ll x=(A*f1+(n-A)%mod*fa1)%mod*nin%mod;
ll y=(A*((A-1)*f2%mod+(n-A)*fa1%mod)+(n-A)*(A*f1%mod+(n-A-1)*fa2%mod))%mod*nin%mod*nin1%mod;
ll z=(A*fa+(n-A)*fn)%mod*nin%mod;
//printf("x=%lld y=%lld z=%lld\n",x,y,z);
a=(z-x-(n-1)*(y+mod-x)%mod+mod+mod)%mod*niv1%mod;
b=(y-x-3*a%mod+mod+mod)%mod;
c=(x-a-b+mod+mod)%mod;
}
int ask=read();
while(ask--){
printf("%lld\n",calc(read()));
}
return 0;
}
边栏推荐
- Static proxy instance
- zotero文献管理器及其使用姿势(不定时更新)
- [general database integrated development environment] Shanghai daoning provides you with Aqua Data Studio downloads, tutorials, and trials
- [pyGame practice] when the end of the world comes, how long can you live in a cruel survival game that really starts from scratch?
- Will PFP be the future of digital collections?
- ES6知识点补充
- R language uses dplyr package group_ By function and summarize function calculate the mean value of all covariates involved in the analysis based on grouped variables (difference in means of covariate
- Left connection and right connection of MySQL (the difference between inner connection and natural connection)
- Shell (I)
- An example of the mandatory measures of Microsoft edge browser tracking prevention
猜你喜欢

Digital twin rail transit: "intelligent" monitoring to clear the pain points of urban operation

一文看懂设备指纹如何防篡改、防劫持

Sirius network verification source code / official genuine / included building tutorial

Leecode8 string conversion integer (ATOI)

Cvpr2020 best paper: unsupervised learning of symmetric deformable 3D objects

Design a system that supports millions of users

Excel shortcut keys (letters + numbers) Encyclopedia

What is the process of switching c read / write files from user mode to kernel mode?

Server online speed measurement system source code

108. Introduction to the usage of SAP ui5 image display control Avatar
随机推荐
[collection] Advanced Mathematics: Capriccio of stars
14、用户web层服务(二)
The fifth generation verification code of "cloud centered, insensitive and extremely fast" is coming heavily
【补题日记】[2022杭电暑期多校2]K-DOS Card
Can dynamic partitions be configured when MySQL is offline synchronized to ODPs
Localization, low latency, green and low carbon: Alibaba cloud officially launched Fuzhou data center
Excel shortcut keys (letters + numbers) Encyclopedia
Globalthis is not defined solution
OsCache缓存监控刷新工具
Go deadlock - when the channel meets mutex
Leecode8 string conversion integer (ATOI)
Cvpr2020 best paper: unsupervised learning of symmetric deformable 3D objects
Dialogue with Zhuang biaowei: the first lesson of open source
R language uses oneway The test function performs one-way ANOVA
什么是WordPress
I/O实操之对象流(序列化与反序列化)
[applet] how to notify users of wechat applet version update?
Byte side: how to realize reliable transmission with UDP?
In order to ensure the normal operation of fire-fighting equipment in large buildings, the power supply monitoring system of fire-fighting equipment plays a key role
1331. Array sequence number conversion