Question one hundred and nine: positive integer solution (2)

Source: Internet
Author: User

[Plain] Description
 
 
X + y + z = n is given a positive integer. n is used to calculate the number of positive integer solutions that meet the conditions.
 
 
Input
 
 
Each group of input data has a positive integer n (n> = 3)
 
 
Output
 
 
Output result
 
 
Sample Input
 
 
3
4
5
 
Sample Output
 
 
1
3
6

Description


X + y + z = n is given a positive integer. n is used to calculate the number of positive integer solutions that meet the conditions.


Input


Each group of input data has a positive integer n (n> = 3)


Output


Output result


Sample Input


3
4
5

Sample Output


1
3
6
 

[Plain] # include <stdio. h>
Int main ()
{
Int m;
Int n;
Int;
Int B;
Int c;

While (scanf ("% d", & n )! = EOF & n> = 3)
{
M = 0;
For (a = 1; a <n; a ++)
{
For (B = 1; B <n-a; B ++)
{
C = n-a-B;
If (c> = 0)
{
M ++;
}
}
}
 
Printf ("% d \ n", m );
}
 
Return 0;
}

# Include <stdio. h>
Int main ()
{
Int m;
Int n;
Int;
Int B;
Int c;

While (scanf ("% d", & n )! = EOF & n> = 3)
{
M = 0;
For (a = 1; a <n; a ++)
{
For (B = 1; B <n-a; B ++)
{
C = n-a-B;
If (c> = 0)
{
M ++;
}
}
}

Printf ("% d \ n", m );
}

Return 0;
}
 

 

 

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.