hdu1015 DFS Violence search all situation templates

Source: Internet
Author: User

Brain a bit of a pit, do not know why, may have encountered a shadow, and now see the DFS violence search a kind of inexplicable fear, summarize the template bar

This question is still boring, direct violence search, but I write very rotten, may be this reason, looked at others template, feel good.

Learned a word "lexicography" dictionary sequence, and eat the loss of culture, WA once

#include <iostream>#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<string>#include<stack>#include<queue>#include<algorithm>Const intINF = (1<< to)-1;Const intMAXN = -;using namespacestd;intVIST[MAXN];CharS[MAXN];//Char TS[MAXN];intTS[MAXN];intLength,n;intFlag;voidDfsintx) {    if(flag)return ; if(x==5){        if(ts[0]-(int) Pow (ts[1],2)+(int) Pow (ts[2],3)-(int) Pow (ts[3],4)+(int) Pow (ts[4],5)==N) {Flag=1; //return;        }        return; }     for(intI=0; i<length&&flag==0; i++){        if(!Vist[i]) {Vist[i]=1; TS[X]= s[i]-'A'+1; DFS (x+1); Vist[i]=0; }    }    return ;}intcmpintAintBB) {    if(A&GT;B)return true; Else return false;}intMain () { while(SCANF ("%d%s", &n,s), strcmp (S,"END")!=0) {flag=0; memset (Vist,0,sizeof(vist)); Length=strlen (s); Sort (s,s+length,cmp); DFS (0); if(flag) { for(intI=0;i<5; i++) {printf ("%c", ts[i]-1+'A'); } cout<<Endl; }Elseprintf ("No solution\n"); }    //cout << "Hello world!" << Endl;    return 0;}
View Code

hdu1015 DFS Violence search all situation templates

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.