ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Codeforces Round #560 (Div. 3)

2022-02-26 22:34:50  阅读:132  来源: 互联网

标签:return cout 560 LL Codeforces int ans Div scanf


Codeforces Round #560 (Div. 3)

A

# include <bits/stdc++.h>
using namespace std;

const int MAXN=2e5+100;
int main()
{
int n,y,x;
string a;
int sum=0;
scanf("%d %d %d",&n,&y,&x);

cin>>a;
//cout<<n<<" "<<y<<" "<<x<<endl;
// for(int i=0;i<n;i++){
// printf("%c",a[i]);
// }
// cout<<endl;

//cout<<a[n-2]<<endl;
if(a[n-1-x]=='0'){
sum++;
}
//cout<<a[n-1-x]<<endl;
//cout<<sum<<endl;
for(int i=n-1;i>=(n-y);i--){
if(i==(n-1-x)) continue;
else{
if(a[i]!='0'){
sum++;
}
}
}

printf("%d",sum);

return 0;
}

B

# include <bits/stdc++.h>
using namespace std;

const int MAXN=2e5+100;
set<int> a;
int main()
{
int n;

scanf("%d",&n);

for(int i=1;i<=n;i++){
int x;
scanf("%d",&x);
a.insert(x);
}

int j=1;
int flag=1;
for(set<int>::iterator it=a.begin();it!=a.end();it++){
//cout<<*it<<" "<<j<<endl;
if(*it<j){
j--;
flag=0;
break;
}else{
j++;
}
}
if(flag){
j--;
}

printf("%d",j);

return 0;
}

C

# include <bits/stdc++.h>
using namespace std;

const int MAXN=2e5+100;
int f[MAXN];
int main()
{
int n;
string a;
int ll;

scanf("%d",&n);
ll=n;
cin>>a;

for(int i=0;i<n;){
if((i+1)>=n) break;
if(a[i]!=a[i+1]){
i+=2;
}else{
f[i]=1;
i++;
ll--;
}
}

if(ll%2!=0){
f[n-1]=1;
ll--;
}

printf("%d\n",(n-ll));
for(int i=0;i<n;i++){
if(f[i]==0){
cout<<a[i];
}
}
return 0;
}

D

# include <bits/stdc++.h>
using namespace std;

typedef long long LL;
LL gcd(LL a,LL b)
{
return b==0?a:gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
return a/gcd(a,b)*b;
}
const LL MAXN=1e6+10;
//LL f[MAXN];
int main()
{
int t;
scanf("%d",&t);

while(t--){
LL n;
LL a[330];
LL ans=1;
LL minn=1e6;
map<LL,bool> b;
//memset(f,0,sizeof(f));
scanf("%lld",&n);
for(int i=0;i<n;i++){
scanf("%lld",&a[i]);
ans=lcm(ans,a[i]);
if(a[i]<minn) minn=a[i];
b[a[i]]=true;
}
if(b[ans]){
ans=ans*minn;
}
printf("%lld\n",ans);
}

return 0;
}



标签:return,cout,560,LL,Codeforces,int,ans,Div,scanf
来源: https://www.cnblogs.com/fengzlj/p/15940741.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有