题意:
给你一个字符串,求他有多少个子串是300的倍数
思路:
O(300n)的dp
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int dp[maxn][310];
typedef long long ll;
int main(){
char s[maxn];scanf("%s",s+1);
int len=strlen(s+1);ll ans=0;
// cout<<s+1<<endl;
for(int i=1;i<=len;i++){
int x=s[i]-'0';x%=300;
dp[i][x]++;
for(int j=0;j<300;j++){
dp[i][(j*10+x)%300]+=dp[i-1][j];
}
ans+=dp[i][0];
}
cout<<ans<<endl;
}