# “华为杯”山东理工大学第十一届ACM程序设计竞赛（正式赛）网络同步赛

A 猜先
Problem Description

Input

Output

Sample Input
2 8
Sample Output
black
Hint

AC代码

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
if(a%2==b%2)
cout<<"black"<<endl;
else
cout<<"white"<<endl;
return 0;
}


B Digit deletion
Problem Description

Input

Output

Sample Input
1 2 3 4 5
Sample Output
10 14
Hint

AC代码

#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int num[5];
int main()
{
for(int i=0;i<5;i++)
cin>>num[i];
sort(num,num+5);
int mmin=num[0]+num[1]+num[2]+num[3];
int mmax=num[4]+num[3]+num[2]+num[1];
cout<<mmin<<" "<<mmax<<endl;
return 0;
}


C 沉心十年
Problem Description

Input

Output

Sample Input
5
Sample Output
SDUTA
C M
S D
U T
ACMSD
Hint

AC代码

#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
char Map[55][55];
string str="SDUTACM";
int main()
{
int n,k=0;
cin>>n;
for(int i=0;i<n;i++)
{
if(i==0||i==n-1)
for(int j=0;j<n;j++)
{
cout<<str[k];
k++;
if(k==str.length())
k=0;
}
else
{
cout<<str[k];
k++;
if(k==str.length())
k=0;
for(int j=1;j<n-1;j++)
cout<<" ";
cout<<str[k];
k++;
if(k==str.length())
k=0;
}
cout<<endl;
}

return 0;
}


E 九连环

1、对每个环，有2种操作：把这个环放到杆上或把这个环从杆上取下
2、你可以随意的对第1个环进行操作
3、如果你想对第i个环(i>1)进行操作，你必须将第i-1个环放在杆上，且必须把前i-2个环从杆上取下

Input

Output

Sample Input
4
Sample Output
2 DOWN
1 DOWN
4 DOWN
1 UP
2 UP
1 DOWN
3 DOWN
1 UP
2 DOWN
1 DOWN

AC代码

#include<iostream>
#include<stdio.h>
using namespace std;
int shangmian[10];
void xie(int n) {
if(n == 1)
{
printf("%d DOWN\n",n);
shangmian[n] = 0;
return;
}
if(shangmian[n - 1] == 0)
zhuang(n - 1);
for (int i = n - 2; i >= 1; i--)
if (shangmian[i] == 1)
xie(i);

printf("%d DOWN\n",n);
shangmian[n] = 0;
return;
}

void zhuang(int n) {
if (n == 1)
{
printf("%d UP\n", n);
shangmian[n] = 1;
return;
}
if (shangmian[n - 1] == 0)
zhuang(n - 1);
for (int i = n - 2; i >= 1; i--)
if (shangmian[i] == 1)
xie(i);

printf("%d UP\n", n);shangmian[n] = 1;
return;
}

int  main()
{
int n;
cin>>n;
for (int i = 0; i < 10; i++)
shangmian[i] = 1;
for (int i = n; i >= 1; i--)
xie(i);
return 0;
}


J 定向运动
Problem Description

Input

Output

Sample Input
4 5
10101
11100
11010
00101
Sample Output
5
2

AC代码

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;
string str[55];
int dp[55][55][505];
int main()
{
int n,m;
int mmax=-1;
int cnt=0;
cin>>n>>m;
for(int i=1;i<=n;i++)
cin>>str[i];
for(int i=1;i<=n;i++)
{
for(int j=i+1;j<=n;j++)
{
for(int k=0;k<m;k++)
dp[i][j][k]=dp[i][j][k-1]+max(str[i][k]-'0',str[j][k]-'0');
if(mmax<dp[i][j][m-1])
{
mmax=dp[i][j][m-1];
cnt=0;
}
if(mmax==dp[i][j][m-1])
cnt++;
}
}
cout<<mmax<<endl;
cout<<cnt<<endl;
}


K 矩形的外接圆

Input

Output

Sample Input
1 1
Sample Output
0.571

AC代码

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int main()
{
double a,b;
cin>>a>>b;
double  pi=3.14159265;
double ans=pi*(a*a+b*b)/4-a*b;
printf("%.3lf\n",ans);
return 0;
}