# AtCoder Beginner Contest 160（A~D）

0
12

A – Coffee

（1）字符串的第3个字母等于字符串的第4个字母

（2）字符串的第5个字母等于字符串的第6个字母

（3）字符串的长度为6，且全部为小写字母

```#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
int main(){
string ptr;
cin>>ptr;
int f=1;
for(int i=0;i<ptr.length();i++){
if(ptr[i]>='A'&&ptr[i]<'Z'){
f=0;
break;
}
}
if(f==0){
cout<<"No"<<endl;
return 0;
}
if(ptr.length()==6){
if(ptr[2]==ptr[3]&&ptr[4]==ptr[5]){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}else{
cout<<"No"<<endl;
}
return 0;
}```

B – Golden Coins

```#include<iostream>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
int main(){
ll mo;
cin>>mo;
ll sum=0;
ll n1=mo/500;
ll n2=(mo%500)/5;
sum=n1*1000+n2*5;
cout<<sum<<endl;
return 0;
}```

C – Traveling Salesman around Lake

```#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll num[200010]={0};
int main(){
ll K,N;
cin>>K>>N;
memset(num,0,sizeof(num));
for(int i=0;i<N;i++){
cin>>num[i];
}
sort(num,num+N);
if(N==1){//只有一个
cout<<0<<endl;
}else if(N==2){//有两个
ll len=num[N-1]-num[0];
cout<<min(len,K-len)<<endl;
}else{//至少有三个及以上
ll min_l=10000000;
ll len[200010]={0},t=0;
ll sum=0;
for(int i=1;i<N;i++){
len[t++]=num[i]-num[i-1];
sum=sum+len[t-1];
}
len[t++]=K-num[N-1]+num[0];
sum=sum+len[t-1];
for(int i=0;i<t;i++){//丢掉第  i  个数
min_l=min(min_l,sum-len[i]);
}
cout<<min_l<<endl;
}
return 0;
}```

D – Line++

```#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll s[2005][2005];
ll ans[2005*2005]={0};
int main(){
ll N,x,y;
cin>>N>>x>>y;
ll a=x,b=y;
x=min(a,b);
y=max(a,b);
for(ll i=1;i<=N;i++){
for(ll j=i+1;j<=N;j++){
s[i][j]=min(j-i,abs(x-i)+abs(y-j)+1);
}
}

for(int i=1;i<=N;i++){
for(int j=i+1;j<=N;j++){
ans[s[i][j]]++;
}
}
for(int i=1;i<N;i++){
cout<<ans[i]<<endl;
}
return 0;
}```

<

0