2021杭电多校第四场
1001 Calculus
思路
可以注意到这几个函数都是发散的,只需要判断系数是否为0就可以了。
附上代码
#include <bits/stdc++.h>
using namespace std;
string strs[101];
void solve(string str)
{
int p = 0;
int cnt = 1;
while((p = str.find("+",p+1)) != -1)
{
str.replace(p,1," ");
cnt++;
}
stringstream ss(str);
for(int i = 1;i <= cnt;i++)
{
ss >> strs[i];
}
for(int i = 1;i <= cnt;i++)
{
if(strs[i][0]!='0')
{
cout << "NO" << endl;
return;
}
}
cout << "YES" << endl;
return;
}
int main()
{
cin.sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
string str;
while(t--)
{
cin >> str;
solve(str);
}
return 0;
}
1002 Kanade Loves Maze Designing
待补
1008 Lawn of the Dead
待补
1009 License Plate Recognition
思路
可以看出只有汉字有可能会被分割为很多个部分,而字母和数字是一定会是一个整体的,因此可以统计每一列的‘#’数量,只需要在第一个符号这里判断一下,而后面的符号直接寻找连续的不为零的区间即可。
附上代码
#include <iostream>
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define mod 1000000007
#define lmax 1000
#define pi 3.141592653589793238462643383279
#define eps 1e-7
using namespace std;
typedef long long ll;
typedef double type;
int biao[103];
int ce[103];
int main()
{
int t;
scanf("%d",&t);
for(int k=1; k<=t; k++)
{
char ch;
memset(biao,0,sizeof(biao));
for(int i=1; i<=30; i++)
{
for(int j=1; j<=100; j++)
{
scanf(" %c",&ch);
//cin>>ch;
if(ch=='#')
biao[j]++;
}
}
int i=1;
int cex=1;
while(i<=100)
{
while(i<=100)
{
if(biao[i]==0)
{
i++;
}
else
{
ce[cex]=i;
cex++;
i++;
break;
}
}
while(i<=100)
{
if(biao[i]==0)
{
ce[cex]=i-1;
i++;
cex++;
break;
}
else
{
i++;
}
}
}
if(cex==15)
{
printf("Case #%d:\n",k);
for(int j=1; j<cex; j+=2)
{
printf("%d %d\n",ce[j],ce[j+1]);
}
}
else
{
int kk=cex-14;
printf("Case #%d:\n",k);
printf("%d %d\n",ce[1],ce[kk+1]);
for(int j=kk+2; j<cex; j+=2)
{
printf("%d %d\n",ce[j],ce[j+1]);
}
}
}
return 0;
}