2269.找到一个数字的k美丽值

Posted by 云起 on 2025-03-10
Estimated Reading Time 1 Minutes
Words 70 In Total
Viewed Times

2269.找到一个数字的k美丽值

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Solution {
public:
int divisorSubstrings(int num, int k) {
if(num==0) return 0;
int ans=0;
string str=to_string(num);
for(int i=0;i<=str.size()-k;i++){
string stmp=str.substr(i,k);
int tmp= atoi(stmp.c_str());
if(tmp!=0&&num%tmp==0) ans++;
}
return ans;
}
};

If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !