作业帮 > 英语 > 作业

一道数学的ACM题.1514:x + 2y + 3z = nTime Limit:1000MS Memory Limit

来源:学生作业帮 编辑:百度作业网作业帮 分类:英语作业 时间:2024/07/02 19:58:46
一道数学的ACM题.
1514:x + 2y + 3z = n
Time Limit:1000MS Memory Limit:65536K
Total Submit:229 Accepted:52
[Submit] [Status] [Discuss]
Font Size:Aa Aa Aa
Description
This problem is so easy:given an positive integer n,you are to find the number of solutions of the equation
x + 2y + 3z = n
where x,y,z are nonnegative integers.
Input
The input contains several lines of a positive integer n ( n < 10^6 ) followed by a zero.
Output
For each positive integer in the input output the number of solutions of the equation.
Sample Input
1
6
0
Sample Output
1
7
代码如下:
#include
#include
void solve(int x)
{
int i;
__int64 ans=0;
for (i=0;i*3
一道数学的ACM题.1514:x + 2y + 3z = nTime Limit:1000MS Memory Limit
for (i=0;i*3