2024-03-07 2024-05-12 problem 几秒读完 (大约105个字) 0次访问lc2575.找出字符串的可整除数组题目链接: 题解 按题意模拟,对中间变量一直模 m。中间过程可能超过 int 范围。 参考代码 12345678910111213141516171819202122232425/* * @lc app=leetcode.cn id=2575 lang=cpp * * [2575] 找出字符串的可整除数组 */// @lc code=startclass Solution {public: vector<int> divisibilityArray(string word, int m) { vector<int> ans; long long p=0; for (int i = 0;i<word.size(); ++i) { p = p*10+word[i]-'0'; if (p%m==0) ans.push_back(1); else ans.push_back(0); p = p%m; } return ans; }};// @lc code=end lc2575.找出字符串的可整除数组https://blog.xiang578.com/problem/lc2575.html作者Ryen Xiang发布于2024-03-07更新于2024-05-12许可协议 LeetCode, implementation