"Hdoj" 1539 shredding Company

Source: Internet
Author: User

Dfs.

1 /*1539*/2#include <iostream>3#include <cstdio>4#include <cstring>5#include <cstdlib>6#include <vector>7 using namespacestd;8 9 #defineINF 0XFFFFFFFTen  One intq[ the]; A Chars[ -]; - intans; - intT, Len; the BOOLFlag; -vector<int>TB; -  - voidDfsintBegintSumintN) { +     intI, J, K, TMP; -      +     if(Beg = =Len) { A         if(Sum<=t && sum>ans) { at tb.clear (); -              for(i=0; i<n; ++i) - Tb.push_back (Q[i]); -Ans =sum; -Flag =false; -n =0; in}Else if(Sum = =ans) { -Flag =true; to         } +         return ; -     } the      *      for(I=beg; i<len; + +)i) { $TMP =0;Panax Notoginseng          for(J=beg; j<=i; + +)j) -TMP =Ten*tmp+s[j]-'0'; theQ[n] =tmp; +DFS (i+1, Sum+tmp, n+1); A     } the } +  - intMain () { $     intI, J, K, TMP; $     intsum; -      - #ifndef Online_judge theFreopen ("data.in","R", stdin); -     #endifWuyi      the      while(SCANF ("%d%s", &t, s)! =EOF) { -         if(t==0&& s[0]=='0'&& s[1]==' /') Wu              Break; -sum =0; AboutTMP =0; $          for(i=0; S[i]; ++i) { -TMP =Ten*tmp+s[i]-'0'; -Sum + = s[i]-'0'; -         } ALen =i; +         if(Sum >t) { theprintf"error\n"); -             Continue; $         } the         if(TMP = =t) { theprintf"%d%s\n", T, s); the             Continue; the         } -Flag =false; inAns =-1; the tb.clear (); theDfs0,0,0); About         if(flag) { theprintf"rejected\n"); the}Else { theprintf"%d", ans); +              for(i=0; I<tb.size (); ++i) -printf"%d", Tb[i]); theprintf"\ n");Bayi         } the     } the      -     return 0; -}

"Hdoj" 1539 shredding Company

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.