#802876

Solution for 0097: Sum of Integers II by dohatsu

Source Code Status Test Cases
    Policy: public     Reviewed: 101    
00.00 sec    1232 KB    32 lines     491 bytes    2013-11-04 21:47
#include<iostream>
using namespace std;
long long dp[10][1001],n,s;
int main(){
	
	for(int i=0;i<10;i++){
		for(int j=0;j<1001;j++)dp[i][j]=0;
	}
	
	for(int i=0;i<1001;i++){
		if(i<=100)dp[1][i]=1;
		else dp[1][i]=0;
	}

	for(int i=2;i<10;i++){
		for(int j=1;j<1001;j++){
			if(j-i>=0)dp[i][j]+=dp[i][j-i];
			if(j-(i-1)>=0)dp[i][j]+=dp[i-1][j-(i-1)];
			if(j-101>=0)dp[i][j]-=dp[i-1][j-101];
		}
	}
	
	while(1){
		cin>>n>>s;
		if(n==0&&s==0)break;
		cout<<dp[n][s]<<endl;
	}
	

	return 0;
}

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

Status
Judge: 4/4 C++ CPU: 00.00 sec Memory: 1232 KB Length: 491 B 2013-11-04 21:47 2013-11-04 21:47
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.00 sec 1232 KB
Case #2: : Accepted 00.00 sec 1232 KB
Case #3: : Accepted 00.00 sec 1232 KB
Case #4: : Accepted 00.00 sec 1232 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags