P11004 题解
本题考验读题 / kel
思路
定义一个二维数组,类似于滚动数组,首维只有 和 。 跳跃从 开始,定义一个变量, 在 , 在 。 枚举 ,从 到 ,如果共鸣,跳到另一个序列,答案加一。
AC Code
#include<bits/stdc++.h>
using namespace std;
#define itn int
// #define int long long
#define ll long long
#define scnaf scanf
#define sacnf scanf
int n;
int x[2][100005];
bool pl;
int ans=0;
bool fuck(int n) //判断是否共鸣
{
if(n==0)
return 1;
while(n)
{
if(n%10==2 || n%10==4 || n%10==0)
return 1;
n=n/10;
}
return 0;
}
signed main()
{
// freopen("P____.in","r",stdin);
// freopen("P____.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
scanf("%d",&n);
for(int i=0;i<2;i++)
for(int j=1;j<=n;j++)
scanf("%d",&x[i][j]);
for(int i=1;i<=n;i++)
if(fuck(x[pl][i])) // 共鸣
pl=1-pl,ans++; // 跳到另一个序列,答案++
printf("%d",ans);
return 0;
}