Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <algorithm>
- #include <string.h>
- using namespace std;
- int cnt=0;
- char str[30];
- int n,_42=1;
- void doit(int pos, int last) {
- if (pos==n) {
- cnt++;
- return;
- }
- int acum=0;
- for (int i=pos; i<n; i++) {
- acum+=str[i]-'0';
- if (acum>=last) doit(i+1,acum);
- }
- }
- int main() {
- while (1) {
- scanf(" %s", str);
- if (!strcmp(str,"bye")) break;
- n=strlen(str); cnt=0;
- doit(0,-1);
- printf("%d. %d\n", _42++,cnt);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement