日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

[BZOJ4403]序列统计

發布時間:2025/4/5 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [BZOJ4403]序列统计 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題意:給定三個正整數N、L和R,統計長度在1到N之間,元素大小都在L到R之間的單調不降序列的數量。輸出答案對10^6+3取模的結果。
我的數學好差啊。。。

推式子見:http://www.cnblogs.com/Var123/p/5546290.html

#include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> #include<iostream> #include<string> #include<ctime> #include<queue> #include<map> #include<set> #include<vector> typedef long long LL; using namespace std; const LL p=1000003; LL T,n,R,L,fac[p+1]; LL read() {LL d=0,f=1; char c=getchar(); while (c<'0'||c>'9') {if (c=='-') f=-1; c=getchar();} while (c>='0'&&c<='9') d=(d<<3)+(d<<1)+c-48,c=getchar(); return d*f;} void judge(){freopen(".in","r",stdin); freopen(".out","w",stdout);} LL quickmi(LL a,LL b) {LL res=1;while (b){if (b&1) res=res*a%p;a=a*a%p; b>>=1;}return res; } LL C(LL n,LL m) {if (n<m) return 0;if (n==m) return 1;return fac[n]*quickmi(fac[m]*fac[n-m]%p,p-2)%p; } LL lucas(LL n,LL m) {LL res=1;while (n&&m&&res){res=res*C(n%p,m%p)%p;n/=p; m/=p;}return res; } int main() {//judge();fac[0]=1;for (int i=1;i<=p;i++) fac[i]=fac[i-1]*i%p;T=read();while (T--){n=read(); L=read(); R=read();LL ans=lucas(n+R-L+1,R-L+1);printf("%lld\n",(ans-1+p)%p);}return 0; } View Code

?

轉載于:https://www.cnblogs.com/lujiaju6555/p/6795935.html

總結

以上是生活随笔為你收集整理的[BZOJ4403]序列统计的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。