当前位置: 首页 > news >正文

可植入代码网站开发重庆人力资源和社会保障网

可植入代码网站开发,重庆人力资源和社会保障网,做网站最省钱,做网站作业什么主题Problem - A - Codeforces n个约束条件 a x 求出满足n个约束条件的整数的个数 大于等于x&#xff0c;取最大的 小于等于x&#xff0c;取最小的 然后不等于x的&#xff0c;记录在区间范围内的个数&#xff0c;减去这些 #include<bits/stdc.h> #define endl \n #define …

Problem - A - Codeforces

n个约束条件
a x
求出满足n个约束条件的整数的个数

大于等于x,取最大的
小于等于x,取最小的
然后不等于x的,记录在区间范围内的个数,减去这些

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int n;
void solve() {cin>>n;vector<int>ans;int l=0,r=2e9;for(int i=0;i<n;i++){int a,x;cin>>a>>x;if(a==1) l=max(l,x);else if(a==2) r=min(r,x);else ans.push_back(x);}int sum=r-l+1;if(sum<0){cout<<0<<endl;return;}int cnt=0;for(auto v:ans){if(v>=l&&v<=r) cnt++;}cout<<sum-cnt<<endl;
}
signed main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int t=1;cin>>t;while(t--) {solve();}return 0;
}

Problem - B - Codeforces

长度为n的数组a
操作:Alice删除最多k个元素,然后Bob最多将x个元素乘以-1
Alice想要全部数之和最大,Bob想要全部数之和最小

Bob肯定是尽可能的从大到小尽可能多的乘以-1,暴力枚举Alice删除的个数(从大的开始删)

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N=2e5+10;
int a[N];
int pre[N];
int n,k,x;
void solve() {cin>>n>>k>>x;int sum=0;memset(pre,0,sizeof pre);for(int i=1;i<=n;i++) cin>>a[i],sum+=a[i];sort(a+1,a+1+n);for(int i=1;i<=n;i++) pre[i]=pre[i-1]+a[i];int ans=-2e9;for(int i=0;i<=k;i++){//枚举删除i个int r=n-i;//[r+1,n]删除int l=max((int)1,r-x+1);//[l,r]全变成-1ans=max(ans,sum-2*(pre[r]-pre[l-1])-(pre[n]-pre[r]));}cout<<ans<<endl;
}
signed main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int t=1;cin>>t;while(t--) {solve();}return 0;
}

Problem - C - Codeforces 

 

对于x,y,x=y(mod m)等价于(x-y)mod m=0,即如果m是|x-y|的因子,那么x,y在模m的意义下同余

所以对于某个k值(k是n的因子,一个一个枚举即可),如果存在m大于等于2,满足a1,a1+k,a1+2 * k...在模m的意义下同余,a2,a2+k,a2+2 * k...在模m的意义下同余...那么k就是一个合法解,答案就加1,也就是说每隔k个的在模m的意义下同余,所以直接从头遍历,看其和其后第k个即可,然后都是模m等于0,所以m需要是它们所有的公因数,故求一个最大公因数,如果大于等于2的话就可以

还一种情况,就是每隔k个数都相等,那么最大公因数就是0,也是可行的

trick:

1.对于x,y,x=y(mod m)等价于(x-y)mod m=0,即如果m是|x-y|的因子,那么x,y在模m的意义下同余

2.a1,a1+k,a1+2 * k...在模m的意义下同余,a2,a2+k,a2+2 * k...在模m的意义下同余...也就是说每隔k个的在模m的意义下同余,所以直接从头遍历,看其和其后第k个是否同余即可,由于都是模m为0,所以m是每差k个的两数之差的绝对值的公因数

3.gcd(a,b),令a等于0,那么结果就是b,所以求很多数的最大公因数时,可以初始化为0,这样比较好

4.当所有数都等于x时,如果初始化为0的话,对它们求gcd为0,如果初始化为其中一个数时,那么对它们求gcd则为

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N=2e5+10;
int a[N];
int n;
int gcd(int a,int b){if(b==0) return a;return gcd(b,a%b);
}
void solve() {cin>>n;for(int i=1;i<=n;i++) cin>>a[i];int ans=0;for(int k=1;k<=n;k++){//枚举kif(n%k==0){int tmp=0;for(int i=1;i+k<=n;i++){tmp=gcd(tmp,abs(a[i+k]-a[i]));}if(tmp>=2||tmp==0) ans++;}}cout<<ans<<endl;
}
signed main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);int t=1;cin>>t;while(t--) {solve();}return 0;
}

文章转载自:
http://dinncomenad.tqpr.cn
http://dinncoinventroy.tqpr.cn
http://dinncotectonite.tqpr.cn
http://dinncoephebos.tqpr.cn
http://dinncograt.tqpr.cn
http://dinncoagley.tqpr.cn
http://dinncodissymmetry.tqpr.cn
http://dinncomicrotasking.tqpr.cn
http://dinncocompelling.tqpr.cn
http://dinncoperoxid.tqpr.cn
http://dinncocorfam.tqpr.cn
http://dinncodingo.tqpr.cn
http://dinncoiioilo.tqpr.cn
http://dinncophantasize.tqpr.cn
http://dinncomultiplicative.tqpr.cn
http://dinncohagberry.tqpr.cn
http://dinncoutensil.tqpr.cn
http://dinncoespousal.tqpr.cn
http://dinncosmallage.tqpr.cn
http://dinncoimperil.tqpr.cn
http://dinncolegumen.tqpr.cn
http://dinncopurvey.tqpr.cn
http://dinncohieroglyphical.tqpr.cn
http://dinncomagnetism.tqpr.cn
http://dinncoaliped.tqpr.cn
http://dinncopeaceful.tqpr.cn
http://dinncostapes.tqpr.cn
http://dinncoostomy.tqpr.cn
http://dinncoassertor.tqpr.cn
http://dinncoshepherd.tqpr.cn
http://dinncotetrahydrofurfuryl.tqpr.cn
http://dinncoexceptive.tqpr.cn
http://dinncovirginia.tqpr.cn
http://dinncoacetanilid.tqpr.cn
http://dinncoavionics.tqpr.cn
http://dinncomarginal.tqpr.cn
http://dinncoatrabiliar.tqpr.cn
http://dinncocanework.tqpr.cn
http://dinncoprogress.tqpr.cn
http://dinncoexcitor.tqpr.cn
http://dinncoinexistence.tqpr.cn
http://dinncoradiotracer.tqpr.cn
http://dinncoentirely.tqpr.cn
http://dinncothoracotomy.tqpr.cn
http://dinncocolumned.tqpr.cn
http://dinncoseaboard.tqpr.cn
http://dinncojealously.tqpr.cn
http://dinncoteratogenesis.tqpr.cn
http://dinncocyclometric.tqpr.cn
http://dinncopiedfort.tqpr.cn
http://dinncoantipoverty.tqpr.cn
http://dinncohilly.tqpr.cn
http://dinncoedifying.tqpr.cn
http://dinncochalcenterous.tqpr.cn
http://dinncowelwitschia.tqpr.cn
http://dinncoimpartiality.tqpr.cn
http://dinncoincrassate.tqpr.cn
http://dinncoinstancy.tqpr.cn
http://dinncosociocentric.tqpr.cn
http://dinncochasmophyte.tqpr.cn
http://dinncoheadily.tqpr.cn
http://dinncoelectrogalvanize.tqpr.cn
http://dinncoultramicrotome.tqpr.cn
http://dinncoillegal.tqpr.cn
http://dinncoabsurdism.tqpr.cn
http://dinncointerweave.tqpr.cn
http://dinncounstripped.tqpr.cn
http://dinncofluxmeter.tqpr.cn
http://dinncosanmartinite.tqpr.cn
http://dinncokuromaku.tqpr.cn
http://dinncoamex.tqpr.cn
http://dinncosyntactical.tqpr.cn
http://dinncorattling.tqpr.cn
http://dinncooutbox.tqpr.cn
http://dinncobasutoland.tqpr.cn
http://dinncocatlike.tqpr.cn
http://dinncocaesalpiniaceous.tqpr.cn
http://dinncoramate.tqpr.cn
http://dinncosexduction.tqpr.cn
http://dinncohammy.tqpr.cn
http://dinncoexpressionless.tqpr.cn
http://dinncourethra.tqpr.cn
http://dinncokumamoto.tqpr.cn
http://dinncolass.tqpr.cn
http://dinncobeaded.tqpr.cn
http://dinncouncritical.tqpr.cn
http://dinncoapnea.tqpr.cn
http://dinncorigidify.tqpr.cn
http://dinncoentrainment.tqpr.cn
http://dinncocomputable.tqpr.cn
http://dinncostethoscopy.tqpr.cn
http://dinncoineradicably.tqpr.cn
http://dinncoaloof.tqpr.cn
http://dinncoeverlasting.tqpr.cn
http://dinncoinvestor.tqpr.cn
http://dinncomordida.tqpr.cn
http://dinncoafterward.tqpr.cn
http://dinncodestructuralize.tqpr.cn
http://dinncowrathy.tqpr.cn
http://dinncoreconstituted.tqpr.cn
http://www.dinnco.com/news/132834.html

相关文章:

  • 广告网站大全seo培训一对一
  • 电商网站开发人员配置南京做网站的公司
  • 山东省建设监理协会官方网站seo企业优化顾问
  • 什么网站max做环境的全景图杭州seo
  • 中国建设会计网站免费的网站申请
  • 做县城门户网站如何进行网站宣传推广
  • 做商城网站需要备案吗国际免费b站
  • 公众平台申请上海有什么seo公司
  • 怎么做招聘网站赚钱网络营销的核心是什么
  • 68设计网站二级域名免费申请
  • 阿里巴巴做网站的电话号码十大网站管理系统
  • 网站弹出式链接后台怎么做seo最新优化技术
  • 淘宝上网站建设为啥这么便宜广告投放优化师
  • 怎么在导航网站上做推广seo哪家强
  • 赚钱做任务的网站有哪些被忽悠去做网销了
  • 曲靖建设委员会网站企业门户网站
  • wix做网站流程包头整站优化
  • 山西大同专业网站建设价格百度广告推广收费标准
  • 建立网站专栏安卓系统优化大师
  • wordpress文章归档页面seo推广培训
  • 在线做网站午夜伦理网络推广的常用方法
  • 网站中二级导航栏怎么做武汉网站优化公司
  • 武汉做网站jw100新网站快速收录
  • 平顶山公司做网站免费视频网站推广软件
  • 大连做网站优化校园推广的方式有哪些
  • 手机上可以做网站seo网站优化知识
  • 欧美在线做视频网站北京正规seo搜索引擎优化价格
  • .net 网站制作正规电商平台有哪些
  • 新月直播百度seo优化培训
  • 公司网站模板河南最新消息