Problem 2728 --Structured Program II - How many ways?

2728: Structured Program II - How many ways?

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $37$ 正确数量 $17$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL

How many ways? 

Write a program which identifies the number of combinations of three integers which satisfy the following conditions:

You should select three integers from 1 to n without duplication.

 A total sum of the three integers is x. 

For example, there are two combinations for n = 5 and x = 9. 

1 + 3 + 5 = 9 

2 + 3 + 4 = 9

The input consists of multiple datasets. For each dataset, two integers n and x are given in a line. 

The input ends with two zeros for n and x respectively. Your program should not process for these terminal symbols.

For each dataset, print the number of combinations in a line.
5 9
0 0
2

3 ≤ n ≤ 100 

0 ≤ x ≤ 300

推荐代码 查看2728 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$0 $ms] 请问一下安科怎么走 449495 2019-07-27 13:25:46
内存最少[$2016 $KB] 请问一下安科怎么走 449495 2019-07-27 13:25:46
第一AC 杨英豪 294057 2018-10-24 11:35:21
第一挑战 杨英豪 294054 2018-10-24 11:29:08

赛题来源/所属竞赛 会津大学《C++ Programming I》 C++程序设计(入门)

竞赛编号 竞赛名称 竞赛时间 访问比赛
1211 庆祝2018年10.24世界程序员节日欢乐AC赛(竞赛密码6的二进制)~ 2018-10-24 10:24:00 请登录