标签:lock content less highlight letters lib esc compute tween
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 13237 Accepted Submission(s): 6897
#include<iostream> #include<cstdio> #include<cmath> #include<map> #include<cstdlib> #include<vector> #include<set> #include<queue> #include<cstring> #include<string.h> #include<algorithm> #define INF 0x3f3f3f3f typedef long long ll; typedef unsigned long long LL; using namespace std; const int N = 1e6+10; const ll mod = 1e9+7; char s[100]; int a[100]; int b[100]; int visited[100]; int n; int flag=0; void DFS(int t){ if(flag==1)return; if(t==6){ int sum1=b[1]+b[3]*b[3]*b[3]+b[5]*b[5]*b[5]*b[5]*b[5]; int sum2=b[2]*b[2]+b[4]*b[4]*b[4]*b[4]; if(sum1-sum2==n){ flag=1; printf("%c%c%c%c%c\n",b[1]-1+‘A‘,b[2]-1+‘A‘,b[3]-1+‘A‘,b[4]-1+‘A‘,b[5]-1+‘A‘); return ; } return ; } for(int i=26;i>=1;i--){ if(visited[i]==1)continue; else if(visited[i]==0&&a[i]==1){ visited[i]=1; b[t]=i; DFS(t+1); visited[i]=0; } } } int main(){ while(scanf("%d %s",&n,s)!=EOF){ if(n==0&&strcmp(s,"END")==0)break; int len=strlen(s); flag=0; memset(a,0,sizeof(a)); for(int i=0;i<len;i++){ int tt=s[i]-‘A‘+1; a[tt]=1; } memset(visited,0,sizeof(visited)); DFS(1); if(flag==0)cout<<"no solution"<<endl; } }
标签:lock content less highlight letters lib esc compute tween
原文地址:http://www.cnblogs.com/Aa1039510121/p/6103390.html