其他分享
首页 > 其他分享> > Codeforces Round #580 (Div. 2)

Codeforces Round #580 (Div. 2)

作者:互联网

Codeforces Round #580 (Div. 2)

A

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

const int MAXN=250;
int a[MAXN],b[MAXN];
int mm[MAXN];
int main()
{
int n,m;
int aa=0,bb=0;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
aa=max(aa,a[i]);
}
scanf("%d",&m);
for(int i=1;i<=m;i++){
scanf("%d",&b[i]);
bb=max(bb,b[i]);
}
printf("%d %d",aa,bb);
return 0;
}

B

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

typedef long long LL;
const int MAXN=1e5+100;
LL a[MAXN];
int main()
{
LL n;
LL fu=0,lin=0,zheng=0;
LL coin=0;
scanf("%lld",&n);
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
if(a[i]<0){
fu++;
coin+=(-1-a[i]);
}else if(a[i]==0){
lin++;
}else{
zheng++;
coin+=(a[i]-1);
}
}
if(fu%2==1){
if(lin){
}else{
coin+=2;
}
}
coin+=lin;
printf("%lld",coin);

return 0;
}

C

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

const int MAXN=2e5+100;
int a[MAXN];
int main()
{
int n;
int sum=0;
scanf("%d",&n);
sum=n*2;
if(n&1){
printf("YES\n");
int flag=1;
a[1]=1,a[n+1]=2;
for(int i=2;i<=n;i++){
if(flag){
a[i]=sum,sum--;
a[n+i]=sum,sum--;
flag=0;
}else{
a[n+i]=sum,sum--;
a[i]=sum,sum--;
flag=1;
}
if(sum==2) break;
}
printf("%d ",a[1]);
for(int i=2*n;i>1;i--) printf("%d ",a[i]);
}else{
printf("NO\n");
}

return 0;
}

D

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

typedef long long LL;
const int MAXN=1e5+100;
LL a[MAXN];
LL mp[MAXN][60];
LL quick_pow(LL a,LL b)
{
LL ret=1;
while(b)
{
if(b&1) ret=ret*a;
a=a*a;
b=b/2;
}
return ret;
}
int main()
{
LL n;
scanf("%lld",&n);
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
LL aa=a[i];
for(int j=59;j>=0;j--){
LL d=quick_pow(2,j);
if(aa/d==0){
continue;
}else{
aa=aa-d;
mp[i][j]=1;
}
}
}
for(int i=1;i<=n;i++){
for(int j=0;j<60;j++){
cout<<mp[i][j]<<" ";
}
cout<<endl;
}
return 0;
}



标签:aa,580,int,LL,scanf,Codeforces,MAXN,Div,sum
来源: https://www.cnblogs.com/fengzlj/p/15940939.html