当前位置: 代码迷 >> 综合 >> ACM-ICPC 2018 徐州赛区网络预赛 I Characters with Hash (模拟水题)
  详细解决方案

ACM-ICPC 2018 徐州赛区网络预赛 I Characters with Hash (模拟水题)

热度:111   发布时间:2023-11-15 16:01:09.0

题目链接:https://nanti.jisuanke.com/t/31461

#include<bits/stdc++.h>
#pragma comment(linker,"/STACK:1024000000,1024000000")
using namespace std;
#define debug puts("YES");
#define rep(x,y,z) for(int (x)=(y);(x)<(z);(x)++)
#define read(x,y) scanf("%d%d",&x,&y)
#define lrt int l,int r,int rt
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ll long long
const int  maxn =1e5+5;
const int mod=1e9+7;
ll powmod(ll x,ll y) {ll t;for(t=1;y;y>>=1,x=x*x%mod) if(y&1) t=t*x%mod;return t;}
ll gcd(ll x,ll y)  {  return y==0?x:gcd(y,x%y); }
char c[5];
int n;
char s[maxn];
int main()
{int t;scanf("%d",&t);while(t--){scanf("%d%s",&n,c);scanf("%s",s);int flag=1,ans=2*n;for(int i=0;i<n;i++){int num=abs(c[0]-s[i]);///cout<<num<<endl;if(flag){if(num==0) ans-=2;else if(num<10) {ans-=1;flag=0;}else flag=0;}}printf("%d\n",ans?ans:1);}return 0;
}

 

  相关解决方案