Square number
0~9 these 10 numbers into groups, each group happens to be a square number, which can be done.
For example: 0, 36, 5948721
Another example:
1098524736
1, 25, 6390784
0, 4, 289, 15376.
Wait a minute...
Note that 0 can be used as a separate number, but not as a start for multiple digits.
When grouping, you must run out of all the numbers, you cannot repeat them, you cannot omit them.
If you do not care about the order of the data in the group, how many different groups of options.
Note: You need to submit an integer, do not fill out the extra content.
Answer: 300
Run in full order, four seconds, here I use the Set container to check the weight, to convert multiple numbers to string type when you should pay attention to standardization, that is, sorting, can not directly operate on the original array, every two number plus a spacer
#include "iostream" #include "algorithm" #include "string.h" #include "math.h" #include <map> #include <set>
using namespace Std;
Long Long shu[20];
int ai[10]={0,1,2,3,4,5,6,7,8,9};
Set<string> JJ;
void dfs (int cur,int num) {if (cur==10) {long long shu2[20];
for (int i=0;i<num;i++) shu2[i]=shu[i];
Sort (shu2,shu2+num);
String Xu;
for (int i=0;i<num;i++) {while (shu2[i]) {int a=shu2[i]%10;
SHU2[I]=SHU2[I]/10;
Char b=a+ ' 0 ';
Xu=xu+b;
} xu+= '-';
} jj.insert (Xu);
return;
} if (ai[cur]==0) {shu[num]=0;
DFS (CUR+1,NUM+1);
else {long long sum=0;
for (int i=cur;i<10;i++) {sum=sum*10+ai[i];
Double son=sqrt (sum); if (son== (int) son) {Shu[num]=sUm
DFS (I+1,NUM+1);
int main () {do {memset (shu,0,sizeof (SHU));
DFS (0,0);
}while (Next_permutation (ai,ai+10));
Cout<<jj.size () <<endl;
return 0; }