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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

牛客练习赛49

發布時間:2024/10/5 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 牛客练习赛49 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Problem A?筱瑪愛地理

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

題意:

題解:逆元+排序

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=200000+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; struct node{int v,e;bool operator<(const node &S)const{return (double)e/v>(double)S.e/S.v;} }G[N]; ll POW(ll a,ll b=MOD-2,ll c=MOD){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",&n);for(int i=1;i<=n;i++)scanf("%d%d",&G[i].v,&G[i].e);sort(G+1,G+n+1);for(int i=1;i<=n;i++)cout<<G[i].e*POW(G[i].v)%MOD<<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/946/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=100+10; const int M=600000+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 f[1<<15],c[20]; int g[1<<15],sz[1<<15]; 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,&m);for(int i=1;i<=n;i++){scanf("%d",&c[i]);sum+=c[i];}sort(c+1,c+n+1);for(int i=1;i<=m;++i) {int s=0;scanf("%d",&k);for(int i=1;i<=k;++i)scanf("%d",&p),s|=(1<<(p-1));g[s]=1;}for(int i=1;i<(1<<n);++i) sz[i]=sz[(i-1)&i]+1;for(int i=0;i<(1<<n);++i) {int s=((1<<n)-1)^i;for(int j=s;j;j=(j-1)&s) if(g[j]) {f[i|j]=max(f[i|j],f[i]+c[sz[i]+1]);}}printf("%d\n",sum-f[(1<<n)-1]);//}#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/946/C

題意:

題解:

C++版本一

?

Problem D?筱瑪愛線段樹

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

題意:第一種操作對[l,r]區間內每幢房子塞入一個皮卡丘; 第二種操作對第l次到第r次的操作重復一遍。

題解:可以 O(n)維護兩個差分數組,一個是針對重復操作的差分數組,一個是針對當前房子塞入皮卡丘的個數的差分數組。對第二個差分數組的每次修改的大小是當前操作重復操作次數。 因為每一次第二種操作總是針對之前的操作,所以要倒著跑一遍。 最后對針對當前房子塞入皮卡丘的個數的差分數組求個前綴和就好了。

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; ll a[N],pre[N]; char str; struct node{int l,r,op; }e[N]; 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(~scanf("%d%d",&n,&m)){memset(pre,0,sizeof(pre));memset(a,0,sizeof(a));pre[m+1]++;pre[0]--;for(int i=1;i<=m;i++){scanf("%d%d%d",&e[i].op,&e[i].l,&e[i].r);}for(int i=m;i>=1;i--){pre[i]=(pre[i]+pre[i+1])%MOD;if(e[i].op!=1){pre[e[i].r]=(pre[e[i].r]+pre[i])%MOD;pre[e[i].l-1]=(pre[e[i].l-1]-pre[i]+MOD)%MOD;}else{a[e[i].l]=(a[e[i].l]+pre[i])%MOD;a[e[i].r+1]=(a[e[i].r+1]-pre[i]+MOD)%MOD;//cout<<e[i].l<<" "<<e[i].r<<" "<<pre[i]<<endl;}}for(int i=1;i<=n;i++){a[i]=(a[i]+a[i-1])%MOD;}for(int i=1;i<=n;i++){printf("%lld%c",a[i]," \n"[i==n]);}}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem E?筱瑪愛游戲

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

題意:
首先,桌面上一共有nn個數。

兩個人輪流從桌面上取走一個數,并把這個數放入集合中。

如果在某次操作結束后,集合中存在一個異或和為00的非空子集,那么進行這次操作的人輸。

如果全部取完,則最后操作的人贏。

題解:線性基

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; ll a[N]; char str; struct node{}; struct Linear_Basis{ll d[63],p[63],tot;void init(){tot=0;memset(d,0,sizeof(d));memset(p,0,sizeof(p));}bool ins(ll x){for(int i=62;i>=0;i--)if (x&(1ll<<i)){if (!d[i]) {d[i]=x;break;}x^=d[i];}return x>0;} } LB; 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++)scanf("%lld",&a[i]);for(int i=1;i<=n;i++){if(LB.ins(a[i]))ans++;}cout<<(ans&1?"First":"Second")<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }

Problem F?筱瑪愛語文

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

題意:

題解:

C++版本一

?

?

總結

以上是生活随笔為你收集整理的牛客练习赛49的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 免费网站看av | wwwwxxx日本 | 欧美视频亚洲视频 | 成年丰满熟妇午夜免费视频 | 手机免费看av | 毛片2 | 翔田千里一区二区三区av | 黄色一级欧美 | 国产欧美亚洲一区二区 | 91麻豆精品一二三区在线 | 国产日日日 | 在线观看污视频网站 | 椎名空在线播放 | 亚洲a在线观看 | 色射视频| 免费高清黄色 | 欧美黄大片 | 精品国产无码在线 | 一区二区三区不卡视频 | 热热色原网址 | 少妇人妻偷人精品无码视频新浪 | 性猛交xxxx乱大交孕妇印度 | 网址av| 国产手机在线视频 | 中文字幕一区二区三区电影 | a级片中文字幕 | 美丽的小蜜桃2:美丽人生 | 欧美视频一二三区 | 国产欧美日韩视频在线观看 | 黄色a一级片 | www.中文字幕av | 狠狠干狠狠艹 | 精品国产乱码久久久久久久软件 | 欧美日韩精品在线观看视频 | 99精品欧美一区二区三区综合在线 | 美女啪啪一区二区 | 久久精品成人一区二区三区蜜臀 | 日本在线精品视频 | 91人妻一区二区三区蜜臀 | 久久久精品人妻一区二区三区色秀 | 亚洲午码| 国产又粗又硬又长又爽的演员 | 加勒比久久综合 | 午夜黄色av | 色妞ww精品视频7777 | 久久视频一区 | 激情三区 | 久久久精品亚洲 | 欧美女优一区 | 欧美少妇精品 | 丰满熟妇乱又伦 | 激情婷婷综合网 | 在线午夜av| 青青草青娱乐 | 欧美区亚洲区 | 日本免费一区二区在线 | 中文字幕11页中文字幕11页 | 我爱avav色aⅴ爱avav | 午夜亚洲 | 91毛片视频 | 蜜臀av一区二区三区 | 五月开心婷婷 | 欧美精品在线免费 | 亚洲AV无码国产日韩久久 | 五月网 | 人人妻人人澡人人爽精品日本 | 四虎成人精品在永久免费 | 黑人操日本 | www.爱爱.com | 女人裸体无遮挡 | 人妖天堂狠狠ts人妖天堂狠狠 | 国产亚洲小视频 | 日日操天天操夜夜操 | 99热在线观看免费 | 日韩网站在线播放 | 九九热最新视频 | 99精品国自产在线 | 国产在线1区 | 男女www| 欧美双性人妖o0 | www.国产精品 | 国产成人精品综合 | 四虎中文字幕 | 国产古装艳史毛片hd | 在线播放你懂得 | 欧美黄色激情视频 | 91一区在线 | 人人草超碰 | 国产精品久久久久免费 | 欧美日韩一区二区电影 | 中文字幕+乱码+中文 | 国产av电影一区二区三区 | 伊人久久久久久久久久久 | 久操久热 | 国产精品第一 | 免费观看黄色网址 | av日韩国产| 欧美老女人bb | 国产一级一区 |