nta1909k7
Giới thiệu
include <iostream>
include <string>
using namespace std;
bool ktra( int b[] , int len , int k )
{
long dem=0,tong=0;
if (len==2){
if (b[0] ==0 || b[1]==0) return false;
}
for (int i=0;i<len;i++)
{
tong+=b[i];
if (tong>k) return false;
}
if (tong!=k) return false;
return true;
}
int main()
{
//freopen("SUBSTR.INP","r",stdin);
//freopen("SUBSTR.OUT","w",stdout);
long n,dem2=0;
string a;
cin>>n;
if (n==0) return 0;
cin>>a;
int b[a.length()];
for (int i=a.length()-1;i>=0;i--)
{
b[i]=a[i]-'0';
}
//xuly
if (ktra(b,a.length(),n)) dem2++;
for (int len=2;len<a.length();len++)
{
int c[len];
for (int i=0;i<a.length()-1 ;i++)
{
int temt2=len;
while (temt2>0)
{
c[temt2-1]=b[i+temt2-1];
temt2--;
}
if (ktra(c,len,n)) dem2++;
}
}
cout<<dem2;
return 0;
}