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

歡迎訪問(wèn) 生活随笔!

生活随笔

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

编程问答

Codeforces Round #654 (Div. 2)

發(fā)布時(shí)間:2023/12/3 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Codeforces Round #654 (Div. 2) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

A.Magical Sticks

貪心湊長(zhǎng)度為nnn的木棒

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<iostream> #include<algorithm> using namespace std; int n; int main() {IO;int T;cin>>T;while(T--){cin>>n;cout<<(n+1)/2<<endl;}return 0; }

B.Magical Calendar

仔細(xì)分析一下這個(gè)題分兩種情況就可以了(畢竟數(shù)據(jù)范圍那么大)

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<iostream> #include<algorithm> using namespace std; typedef long long ll; ll n,r; int main() {IO;int T;cin>>T;while(T--){cin>>n>>r;ll res;if(n>r) res=1ll*(1+r)*r/2;else res=1ll*n*(n-1)/2+1;cout<<res<<endl;}return 0; }

C.A Cookie for You

第三題讀題讀蒙了。。最后發(fā)現(xiàn)第一種人很聽(tīng)話有東西就可以吃,所以盡可能先滿足第二種人就可

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<iostream> #include<algorithm> using namespace std; typedef long long ll; ll a,b,n,m; int main() {IO;int T;cin>>T;while(T--){cin>>a>>b>>n>>m;if(n+m>a+b) cout<<"No"<<endl;else{if(a>b){if(b>=m&&a+b-m>=n) cout<<"Yes"<<endl;else cout<<"No"<<endl;}else{if(a>=m&&b+a-m>=n)cout<<"Yes"<<endl;else cout<<"No"<<endl;}}}return 0; }

哎~~又是只做了三個(gè)題

D.Grid-00100

第四題后來(lái)發(fā)現(xiàn)只有兩種情況,如果學(xué)過(guò)線性代數(shù)應(yīng)該更容易想(求矩陣行列式時(shí)需要找不同行不同列的數(shù),我們就按照那樣構(gòu)造矩陣就行)慚愧學(xué)過(guò)線代還是沒(méi)做出來(lái),我tcl

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef long long ll; const int N=310; char g[N][N]; int n,k; int main() {IO;int T;cin>>T;while(T--){cin>>n>>k;memset(g,'0',sizeof g);if(k%n==0) cout<<0<<endl;else cout<<2<<endl;int i=0,j=0;while(k--){g[i++][j++]='1';j=j%n;if(i==n) i=0,j++;}for(int i=0;i<n;i++){ for(int j=0;j<n;j++)cout<<g[i][j];cout<<endl;}}return 0; }

E1. Asterism (Easy Version)

先找出數(shù)組中最大值mmm,然后分析可以知道當(dāng)x<m?n+1x<m-n+1x<m?n+1時(shí)最終肯定不能全部擊敗,當(dāng)x≥mx\ge mxm時(shí),不管按照任何順序都能夠打完,由于p≤np\leq npn分析可知f(x)f(x)f(x)一定能夠被ppp整除,取m?n+1≤x<mm-n+1\leq x<mm?n+1x<m即可,然后根據(jù)乘法原理模擬求一下方案數(shù)(這里不一定要把方案數(shù)求出來(lái),求排列數(shù)過(guò)程中的因子能被ppp整除那么該xxx不滿足題目意思,如果因子都不能被ppp整除那么滿足)
時(shí)間復(fù)雜度O(n2)O(n^2)O(n2)

#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0) #include<iostream> #include<algorithm> #include<vector> using namespace std; typedef long long ll; const int N=2010; int a[N],n,p; vector<int> ans; int main() {IO;cin>>n>>p;int m=0;for(int i=0;i<n;i++) {cin>>a[i];m=max(m,a[i]);}sort(a,a+n);for(int x=m-n+1;x<m;x++)//枚舉初始的x{int flag=1;int j=0;for(int i=0;i<n-1;i++)//第幾輪{for(j;j<n;j++) if(x+i<a[j]) break;//尋找現(xiàn)在能夠打敗多少個(gè)怪獸if((j-i)%p==0) //j-i就是能夠打敗的并且之前沒(méi)有打過(guò)的{flag=0;//做個(gè)標(biāo)記就可break;}}if(flag) ans.push_back(x);}cout<<ans.size()<<endl;for(auto t:ans) cout<<t<<" ";cout<<endl;return 0; }

總結(jié)

以上是生活随笔為你收集整理的Codeforces Round #654 (Div. 2)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

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