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

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

牛客小白月赛14

發(fā)布時(shí)間:2024/10/5 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 牛客小白月赛14 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Problem A?簡(jiǎn)單計(jì)數(shù)

https://ac.nowcoder.com/acm/contest/879/A

題意:

題解:矩陣快速冪+構(gòu)造矩陣

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100+10; const int M=100000+10; const int MOD=998244353; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; ll t,n,m,k,p,l,r,u,v; int cnt,flag,temp,sum; int a[N];struct Matrix{int n;Matrix(int nn = 1):n(nn){ memset(a,0,sizeof(a));};long long a[N][N];void print(){for(int i = 0;i <= n; ++i)for(int j= 0;j <= n; ++j)printf("%lld%c",a[i][j]," \n"[j==n]);}Matrix operator*(const Matrix &b)const{Matrix c(n);for(int i = 0;i <= n; ++i){for(int j = 0;j <= n; ++j){for(int k = 0;k <= n; ++k){c.a[i][j] += a[i][k] * b.a[k][j];c.a[i][j] %= MOD;}}}//c.print();return c;} }; Matrix ans,fac; ll POW(ll a,ll b,ll c){ll res=1;ll base=a%c;while(b){if(b&1)res=(res*base)%c;base=(base*base)%c;b>>=1;}return res; }void MatrixPOW(ll k){while(k){if(k&1)ans=ans*fac;fac=fac*fac;k>>=1;} } void init(){ans.n = fac.n = 2;ans.a[0][0] = 1;ans.a[1][1]=1;ans.a[0][1] = 0;fac.a[0][0] = 0;fac.a[0][1] = n-1;fac.a[1][0] = 1;fac.a[1][1] = n-2; } int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%lld%lld",&n,&k);init();//ans.print();//fac.print();MatrixPOW(k);//ans.print();cout<<ans.a[0][0]<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem B?投硬幣

https://ac.nowcoder.com/acm/contest/879/B

題意:

題解:乘法逆元+概率

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const ll MOD=998244353; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; ll t,n,m,k,p,l,r,u,v; ll ans,cnt,flag,temp,sum; ll a[N]; char str; struct node{}; ll POW(ll a,ll b,ll c){//cout<<a<<" "<<b<<" "<<c<<endl;if(a==0)return 1;ll res=1;ll base=a%c;while(b){if(b&1)res=(res*base)%c;base=(base*base)%c;b>>=1;}return res; } int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){a[1]=1;a[0]=1;for(int i=2;i<N;i++)a[i]=(a[i-1]*i)%MOD;scanf("%lld%lld%lld",&n,&k,&p);ans=0;for(int i=k;i<=n;i++){ans=(ans+((a[n]*POW(p,i,MOD)%MOD)*POW((1-p+MOD)%MOD,n-i,MOD)%MOD)*POW(a[i]*a[n-i]%MOD,MOD-2,MOD)%MOD)%MOD;}cout<<ans<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem C?植樹造林

https://ac.nowcoder.com/acm/contest/879/C

題意:

題解:數(shù)學(xué)+思維

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);cout<<(n%2?1:2)<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem D?簽到題I

https://ac.nowcoder.com/acm/contest/879/D

題意:

題解:排序

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; int ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d%d",&n,&k);for(int i=1;i<=n;i++)scanf("%d",&a[i]);sort(a+1,a+n+1);cout<<a[k]<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem E?等比數(shù)列三角形

https://ac.nowcoder.com/acm/contest/879/E

題意:

題解:

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; ll ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);ans = 0;double e = (1 + sqrt(5)) / 2;for(int i = 1; i * i <= n; i++)for(int j = i; j <= e * i; j++)if(__gcd(i, j) == 1) ans = (ans + n / j / j)%MOD;cout << ans << endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

?C++版本二

#include<bits/stdc++.h> using namespace std; #define LL long long #define endl '\n' const int mod=1e9+7; LL n; double e=(1.0+sqrt(5.0))/2; LL b[5000]; int main() {while(cin>>n){LL ans=n;int sqr=sqrt(n);for(int i=2;i<=sqr;i++){b[i]=i-(int)(i/e)-1;}for(int i=2;i<=sqr;i++){for(int j=i*2;j<=sqr;j+=i){b[j]-=b[i];}ans=(ans+(n/(i*i))*b[i])%mod;}cout<<ans<<endl;}return 0; }

Problem F?樂色王傳奇

https://ac.nowcoder.com/acm/contest/879/F

題意:

題解:

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=2500+10; const int M=10000000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; ll ans,cnt,flag,temp=1,sum; int a[N][N],inv[N]; int vis[N]; char str; struct node{int v,id;node(){};node(int _v,int _id){v=_v,id=_id;}bool operator <(const node &S)const{return v<S.v;} }e[M]; ll POW(ll a,ll b,ll c){ll res=1;ll base=a%c;while(b){if(b&1)res=(res*base)%c;base=(base*base)%c;b>>=1;}return res; } int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)scanf("%d",&a[i][j]),e[(i-1)*n+j]=node(a[i][j],i);sort(e+1,e+n*n+1);int zercnt=n;inv[1]=1;for(int i=2;i<=n;i++)inv[i]=1LL*(MOD-MOD/i)*inv[MOD%i]%MOD;for(int i=1;i<=n*n;i++){if(!vis[e[i].id]++)zercnt--;if(vis[e[i].id]>1)temp=1LL*temp*inv[vis[e[i].id]-1]%MOD*vis[e[i].id]%MOD;if(!zercnt)ans=(ans+1LL*temp*inv[vis[e[i].id]]%MOD*e[i].v)%MOD;}printf("%lld\n",1LL*ans*POW(POW(n,n,MOD),MOD-2,MOD)%MOD);//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem G?many sum

https://ac.nowcoder.com/acm/contest/879/G

題意:

題解:樸素

C++版本一

#include<bits/stdc++.h> using namespace std; const int maxn = 2e6 + 5; int a1[maxn]; long long b[maxn]; int main() {int n,a,m;cin >> n >> a >> m;a1[1] = a;for(int i = 2; i <= n;i++){a1[i] = (a1[i - 1] + 7 * i) % m;}for(int i = 1; i <= n;i++){for(int j = i; j <= n; j+=i){b[j]=b[j]+a1[i];}}long long ans = 0;for(int i = 1; i <= n;i++){ans^=b[i];}cout << ans << endl; }

Problem H?圖上計(jì)數(shù)

https://ac.nowcoder.com/acm/contest/879/H

題意:

題解:

C++版本一

?

Problem I?有毒的玻璃球

https://ac.nowcoder.com/acm/contest/879/I

題意:

題解:積性函數(shù)+快速冪

C++版本一

/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=10000000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; ll ans,cnt,flag,temp,sum; int a[N]; char str; struct node{}; ll D[M]; int pre[M]; bool prime[M]; ll POW(ll a,ll b,ll c){//cout<<a<<" "<<b<<" "<<c<<endl;if(a==0)return 1;ll res=1;ll base=a%c;while(b){if(b&1)res=(res*base)%c;base=(base*base)%c;b>>=1;}return res; } int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d%d",&n,&k);D[1]=1;prime[0]=prime[1]=1;for(int i=2;i<M;i++){if(!prime[i]){D[i]=POW(i,k,MOD);pre[++cnt]=i;}for(int j=1;j<=cnt&&i*pre[j]<M;j++){prime[i*pre[j]]=1;D[i*pre[j]]=(D[i]*D[pre[j]])%MOD;if(i%pre[j]==0){break;}}//cout<<i<<" "<<D[i]<<endl;}for(int i=1;i<=n;i++){ans=(ans+(n/i)*D[i]%MOD)%MOD;}cout<<ans<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem J?J.I

https://ac.nowcoder.com/acm/contest/879/J

題意:

題解:

C++版本一

?

?

總結(jié)

以上是生活随笔為你收集整理的牛客小白月赛14的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 日韩爱爱视频 | 免费看黄色的视频 | 乱淫的女高中暑假调教h | 国产精品视频不卡 | 日韩午夜在线观看 | 香港三日本8a三级少妇三级99 | 夜夜躁狠狠躁日日躁av | 久色| 日韩激情久久 | 韩国成人在线视频 | 日本中文在线 | 亚州av在线 | 99热视| 精品久久网站 | 精品无码m3u8在线观看 | 性感av在线 | wwwxxx在线观看| 美丽的姑娘观看在线播放 | 国产网站视频 | 西西人体做爰大胆gogo | 欧美黄色短视频 | a级黄色片 | 久久久久爱 | 性视频一区 | xvideos成人免费视频 | 国产成人无码精品 | 久热这里只有精品在线 | 美女作爱网站 | 东北少妇bbbb搡bbb搡 | 亚洲黄色片免费看 | 色婷婷aⅴ一区二区三区 | 邻家有女4完整版电影观看 欧美偷拍另类 | 一区二区三区国产在线观看 | 色播放| 三级小视频在线观看 | 黄色最新网址 | 俄罗斯av在线 | 无码精品人妻一区二区三区湄公河 | 国产成人愉拍精品久久 | 爱豆国产剧免费观看大全剧集 | 亚洲好看站 | 国产情侣激情自拍 | 女人叉开腿让男人桶 | 亚洲第一黄色网址 | 日韩亚洲精品中文字幕 | 国产精品久久久久久妇女6080 | 亚洲欧美日韩在线不卡 | 第一页综合 | 国产精品一二三区 | 亚洲天堂五月天 | 222aaa| 自拍偷拍99 | 婷婷午夜激情 | 好男人www社区在线视频夜恋 | 国产亚洲精品久久久久久777 | 国产高清在线观看 | 欧洲一级视频 | 成人高清视频免费观看 | 一本大道久久 | xxx日本黄色 | 亚洲激情网址 | 春闺艳妇(h)高h产乳 | 天天操夜夜操 | 麻豆传媒mv | 欧美成人女星 | 亚洲午夜福利一区二区三区 | 6080午夜伦理| 91精品视频免费在线观看 | 九九精品在线观看视频 | 亚洲一区二区三区免费看 | 涩涩涩涩涩涩涩涩涩涩 | 亚洲一区二区精品视频 | 一区二区三区免费看视频 | 一级黄色片免费 | 国产www在线观看 | 深夜视频在线观看 | 精品69 | 久久精品电影网 | 午夜亚洲aⅴ无码高潮片苍井空 | 精品1卡二卡三卡四卡老狼 日韩三级网 | 日韩视频福利 | 337p粉嫩大胆噜噜噜亚瑟影院 | 久久午夜无码鲁丝片午夜精品 | 中文字幕自拍 | 丰满圆润老女人hd | 国产无套丰满白嫩对白 | 三级在线看中文字幕完整版 | 国产九九在线 | 国产日韩欧美高清 | 天天艹夜夜 | 亚洲天堂手机版 | 国产精品久久久久久亚洲av | 亚色中文字幕 | 国产亚洲二区 | 欧美激情va永久在线播放 | 国产精品久久婷婷 | 能免费看18视频网站 | www中文在线 | 欧美一二三区 |