2025 是个神奇的数字,因为它是由两个数 20 和 25 拼接而成,而且 。小杨决定写个程序找找小于 的正整数中共有多少这样神奇的数字。该函数的时间复杂度为 ( )。。
#include <string>
int count_miracle(int N) {
int cnt = 0;
for(int n = 1; n * n < N; n++) {
int n2 = n * n;
std::string s = std::to_string(n2);
for (int i = 1; i < s.length(); i++)
if(s[i]!='0'){
std::string s1 = s.substr(0,i);
std::string sr = s.substr(i);
int n1 = std::stoi(s1);
int nr = std::stoi(sr);
if(___ )//在此处填入选项
cnt++;
}
}
return cnt;
}
- A.
- B.
- C.
- D.