fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long ncr(int n,int r)
  5. { long long result=1,temp=1;
  6. for(int i=1;i<=n;i++)
  7. temp*=i;
  8. result*=temp;temp=1;
  9. for(int i=1;i<=r;i++)
  10. temp*=i;
  11. result/=temp;
  12. temp=1;
  13. for(int i=1;i<=n-r;i++)
  14. temp*=i;
  15. result/=temp;
  16.  
  17. return result;
  18.  
  19. }
  20.  
  21. long long func(long long contino)
  22. { int i=1;long long res;
  23. while(contino-i>=i){
  24. res +=ncr(contino-i,i);
  25. i++;}
  26. return res;
  27. }
  28.  
  29. int main() {
  30. std::ios::sync_with_stdio(false);
  31. string s;
  32. long long continous,result,temp,mark,x;
  33. cin>>s;
  34. while((s.length()!=1)&&s[0]!='0'){
  35. result=1;continous=1;result=1;temp=1;mark=0;
  36. for(int i=0;i<s.length()-1;i++)
  37. {if((s[i]=='1')||((s[i]=='2')&& s[i+1]<103))
  38. { continous++;
  39. mark=1;
  40.  
  41. }
  42. else{
  43. if(mark==1)
  44. {x = func(continous);
  45. temp=temp*x;
  46. cout<<"debug";
  47.  
  48. continous=1;mark=0;
  49.  
  50. }
  51.  
  52. }
  53.  
  54.  
  55. }
  56. if(mark==1)
  57. {x = func(continous);
  58. temp=temp*x;
  59. cout<<"debug"<<temp;
  60.  
  61. continous=1;mark=0;
  62. }
  63. cin>>s;
  64. }
  65. // your code goes here
  66. return 0;
  67. }
Success #stdin #stdout 0s 16064KB
stdin
11111
0
stdout
debug7