Codeforces Round #654 (Div. 2)
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 mx≥m時(shí),不管按照任何順序都能夠打完,由于p≤np\leq np≤n分析可知f(x)f(x)f(x)一定能夠被ppp整除,取m?n+1≤x<mm-n+1\leq x<mm?n+1≤x<m即可,然后根據(jù)乘法原理模擬求一下方案數(shù)(這里不一定要把方案數(shù)求出來(lái),求排列數(shù)過(guò)程中的因子能被ppp整除那么該xxx不滿足題目意思,如果因子都不能被ppp整除那么滿足)
時(shí)間復(fù)雜度O(n2)O(n^2)O(n2)
總結(jié)
以上是生活随笔為你收集整理的Codeforces Round #654 (Div. 2)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 谷歌做了个官方手游模拟器谷歌做了个官方手
- 下一篇: Codeforces Round #65