2.答案300
刁丝卫代码,比赛时long long写成int,结果成了263。。。一等擦肩而过。。。
#include <iostream>
#include <fstream>
#include <cstring>
#define LL long long
using namespace std;
bool mark[];
LL res[],sum=;
bool tmpmark[];
bool judge(LL x){
memset(tmpmark,,sizeof(tmpmark));
if(x==){
if(mark[] == )
return false;
return true;
}
while(x!=){
if(mark[x%] || tmpmark[x%])
return false;
tmpmark[x%] = ;
x/=;
}
return true;
} int update(LL x,int coun){
if(x==){
mark[x] = ;
coun++;
return coun;
}
while(x!=){
mark[x%] = ;
x/=;
coun++;
}
return coun;
} void reupdate(LL x){
if(x==){
mark[x] = ;
return ;
}
while(x!=){
mark[x%] = ;
x/=;
}
} void dfs(int coun,int rescoun,LL last){
if(coun == ){
for(int i=;i<rescoun;i++)
cout<<res[i]<<' ';
cout<<">>>"<<sum<<endl;
sum++;
return ;
}
for(LL i=last;i<;i++){
if(judge(i*i)){
int tmpcoun = update(i*i,coun);
res[rescoun] = i*i;
dfs(tmpcoun,rescoun+,i+);
reupdate(i*i);
}
}
}
int main (){
memset(mark,,sizeof());
dfs(,,);
cout<<sum;
return ;
}