fork download
  1. /**
  2. ** author:XiaKIsGod
  3. ** time:2019.1
  4. **/
  5. #include <bits/stdc++.h>
  6. #define LL long long
  7. #define pb push_back
  8. using namespace std;
  9. const int N = 1000000;
  10. int T;
  11. LL ans=0;
  12. LL sum1=0,sum2=0;
  13. string str;
  14. void dfs(int pos,LL now,LL x,bool tag){
  15. if(pos==str.size()){
  16. if(sum1==now+x&&tag){
  17. //cout<<sum1<<' '<<now+x<<endl;
  18. ans++;
  19. }
  20. return;
  21. }
  22. if(!tag){
  23. sum1=now+x;
  24. dfs(pos+1,0,str[pos]-'0',true);
  25. }
  26. dfs(pos+1,now,x*10+str[pos]-'0',tag);
  27. dfs(pos+1,now+x,str[pos]-'0',tag);
  28. }
  29. int main()
  30. {
  31. ios::sync_with_stdio(false);
  32. while(cin>>str){
  33. if(str=="END")
  34. break;
  35. ans=sum1=sum2=0;
  36. dfs(0,0,0,0);
  37. cout<<ans/2<<endl;
  38. }
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty