本文主要是介绍codeforce round 735div2 -32,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
属于是打完多校脑子不转了,这题明明这简单的
掉大分,还好今天还一场
A 题意
选择一个连续子区间,让最大*最小值最大。
A 思路
显然是区间长为2时最大,扫一下就可以了。
想想也知道,我们选择两个时,拓展也是向两边拓展,如果有更小的,显然不拓展为好,如果有介于最大最小之间的,那么答案不会更优,假如有大于最大的,拓展后的答案也不会优于选择那个更大的数的长为二区间。
A 代码
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long
//#define double long double
using namespace std;typedef long long ll;const int maxn=400505;const int inf=0x3f3f3f3f;int n,m,k;void YES(){cout<<"YES"<<endl;}void NO(){cout<<"NO"<<endl;}int a[maxn];void solve(){cin>>n;for(int i=1;i<=n;i++){cin>>a[i];}int ans=-1;for(int i=1;i<n;i++)ans=max(ans,a[i]*a[i+1]);cout<<ans<<endl;}signed main(){IOS#ifndef ONLINE_JUDGEfreopen("IO\\in.txt","r",stdin);freopen("IO\\out.txt","w",stdout);#endifint tn=1;cin>>tn;while(tn--){solve();}}
B 题意
找出最大ij-k(ai|aj)k最大100,ai<=n。
B 思路
啥b题,取后几百位暴力就行
B 代码
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
#define int long long
//#define double long double
using namespace std;typedef long long ll;const int maxn=400505;const int inf=0x3f3f3f3f;int n,m,k;void YES(){cout<<"YES"<<endl;}void NO(){cout<<"NO"<<endl;}int arr[maxn];void solve(){cin>>n>>k;for(int i=1;i<=n;i++){cin>>arr[i];}int ans=-inf;int li=max(1ll,n-600);for(int i=n;i>=li;i--)for(int j=i-1;j>=li;j--){ans=max(ans,i*j-k*(arr[i]|arr[j]));}cout<<ans<<endl;}signed main(){IOS#ifndef ONLINE_JUDGEfreopen("IO\\in.txt","r",stdin);freopen("IO\\out.txt","w",stdout);#endifint tn=1;cin>>tn;while(tn--){solve();}}
C 题意
求MEX{n^ i(1<=i<=m)}
C 思路
显然是让我们找最小的i,使得i^n大于m,按位贪心就好了。
C 代码
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long
//#define double long double
using namespace std;typedef long long ll;const int maxn=400505;const int inf=0x3f3f3f3f;int n,m,k;void YES(){cout<<"YES"<<endl;}void NO(){cout<<"NO"<<endl;}void solve(){cin>>n>>m;if(m<n){cout<<0<<endl;return ;}m++;int ans=0;bool f=0;bool f1=0;int index;for(int i=31;~i;i--){if(m&(1<<i)){if((n&(1<<i))==0){ ans|=(1<<i);}}else{if(!f){if(n&(1<<i)){f=1;break;}}}}/* for(int i=0;;i++){if((n^i)>m){cout<<i<<endl;return;}} */cout<<ans<<endl;}signed main(){IOS#ifndef ONLINE_JUDGEfreopen("IO\\in.txt","r",stdin);freopen("IO\\out.txt","w",stdout);#endifint tn=1;cin>>tn;while(tn--){solve();}}
D 题意
构造一个长为n的串,让他的每一个子串出现次数都是奇数
D 思路
啥b题,形式是aaabaaaac这种。
D 代码
#include<cstdio>
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<string>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<chrono>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"
//#define int long long
//#define double long double
using namespace std;typedef long long ll;const int maxn=400505;const int inf=0x3f3f3f3f;int n,m,k;void YES(){cout<<"YES"<<endl;}void NO(){cout<<"NO"<<endl;}void solve(){cin>>n;if(n==1){cout<<'a'<<endl;return ;}if(n%2){cout<<string(n/2,'a')+'b'+string(n/2-1,'a')+'c'<<endl;}else{cout<<string(n/2,'a')+'b'+string(n/2-1,'a')<<endl;}}signed main(){IOS#ifndef ONLINE_JUDGEfreopen("IO\\in.txt","r",stdin);freopen("IO\\out.txt","w",stdout);#endifint tn=1;cin>>tn;while(tn--){solve();}}
这篇关于codeforce round 735div2 -32的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!