0分过自测求助
查看原帖
0分过自测求助
737194
Error_Mean_Correct楼主2025/2/4 17:43
#include<bits/stdc++.h>
using namespace std;
string S;
int p,num[8],length,ans;
bool judge(int a,int b)
{
	int tmp=0;
	for(int i=a;i<=b;i++)
		tmp=tmp*10+num[i];
	return tmp%p==0;
}
int main()
{
	cin>>p>>S;
	length=S.size();
	for(int i=0;i<length;i++)
		num[i+1]=S[i]-'0';
	for(int i=1;i<=length;i++)
		for(int j=i;j<=length;j++)
			if(judge(i,j))
				ans++;
	cout<<ans;
	return 0;
}

开o2=RE,不开WA

2025/2/4 17:43
加载中...