#1151194

Solution for 0030: Sum of Integers by seungri

Source Code Status Test Cases
    Policy: public     Reviewed: 62    
00.00 sec    600 KB    33 lines     425 bytes    2014-12-09 17:00
#include <stdio.h>

int count;

void han(int x, int s, int n, int sum, int y)
{
	if (y == n || x == 10) {
		if (sum == s && y == n) {
			count++;
		}
		return ;
	}
	han(x + 1, s, n, sum + x, y + 1);
	han(x + 1, s, n, sum, y);
}
		
int main(void)
{
	int s, n, x, y;
	
	while (1) {
		scanf("%d %d", &n, &s);
		if (n == 0 && s == 0) {
			break;
		}
		han(0, s, n, 0, 0);
		printf("%d\n", count);
		count = 0;
	}
	
	return (0);
}

Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 1/1 C CPU: 00.00 sec Memory: 600 KB Length: 425 B 2014-12-09 17:00 2014-12-09 17:00
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.00 sec 600 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags