心得体会
今天参加了暑假集训的第二次组队赛,我之前基本上没有接触过团队打比赛,算上今天是第三次(大一上学期有个擂台赛),所以显得有点生疏,当然收获也是满满的。团队赛不仅仅考验一个团队,更是对每一个队员的考验。我们都知道木桶效应,最短板决定了水的上限,我认为我的能力还远远不够,因为前几次个人赛我的成绩不是很理想,所以我要更加努力,追上成绩靠前的同学。我相信在每个队员的努力下,团队的成绩会越来越好,也只有每个队员都努力才能达到1+1+1>3的效果。 加油,未来在等着我们!
补题
今天的题目我感觉整体比上次的难,做到后面就一点思路都没有了(大概是太菜了,哈哈)。
链接: link.
这个题输入的数都在100以内,所以直接采取暴力解决,这个题目与计算鞍点类似
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;
int main()
{
freopen("lucky.in", "r", stdin);//千万别忘了这两行,题目要求的,我没注意多wa了两次
freopen("lucky.out", "w", stdout);
int n,m,sum,k=0;
int a[110][110];
cin>>n>>m;
memset(a,0,sizeof(a));
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
cin>>a[i][j];
}
}
sum = 4*n*m;//一共n*m个点,每个点有4个方向
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{//暴力遍历,判断上下左右四个方向,我们判断如果该点小则加一并跳出循环
// 我们找到所有小于的个数,用总数sum减去
for(int y=j-1; y>0; y--)
{
if(a[i][j]<=a[i][y])
{
k++;
break;
}
}
for(int y=j+1; y<=m; y++)
{
if(a[i][j]<=a[i][y])
{
k++;
break;
}
}
for(int x=i-1; x>0; x--)
{
if(a[i][j]<=a[x][j])
{
k++;
break;
}
}
for(int x=i+1; x<=n; x++)
{
if(a[i][j]<=a[x][j])
{
k++;
break;
}
}
}
}
sum-=k;
cout<<sum<<endl;
return 0;
}
链接: link.
题目要求我们求得到的最大值,我们只需对‘-’后的数字进行处理,对于’+'后的数字不做处理,这样得到的数为最大值
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
using namespace std;
char str[1010];
int main()
{
freopen("easy.in", "r", stdin);
freopen("easy.out", "w", stdout);
cin>>str;
int top = 0;
while(str[top]!='\0')
{
if(str[top]!='-')//对于'+'后面的数字我们不做处理
{
printf("%c",str[top]);
top++;
}
else//我们只对'-'后面的数字进行处理
{
printf("%c",'-');
top++;
printf("%c",str[top]);//'-'后面的第一个数字我们直接输出
top++;
while(str[top]=='0'&&str[top]!='\0')//因为数字首位不能为0,所以我们从'-'后第二个数判断是否为0
{
printf("%c%c",'+','0');//如果为0就加一个'+'
top++;
}
if(str[top]>'0'&&str[top]<='9')//如果数在0~9(不为0)之间,则这之后的数作为整体输出,直到遇到下一个运算符或到字符串尾
{
printf("%c",'+');
while(str[top]!='+'&&str[top]!='-'&&str[top]!='\0')//注意判断是否到了字符串末尾
{
printf("%c",str[top]);
top++;
}
}
}
}
return 0;
}