fork download
  1. // 1-7-B
  2. #include <stdio.h>
  3. int main(void){
  4. int n, x, ans, i, j, k;
  5. while(1){
  6. ans = 0;
  7. scanf("%d%d", &n, &x);
  8. if(n == 0 && x == 0) break;
  9. for(i = 1; i <= n; ++i){
  10. for(j = i+1; j <= n; ++j){
  11. for(k = j+1; k <= n; ++k){
  12. if(i+j+k == x) ++ans;
  13. }
  14. }
  15. }
  16. printf("%d\n", ans);
  17. }
  18. return 0;
  19. }
Success #stdin #stdout 0s 2012KB
stdin
33 4
8 10
0 0
stdout
0
4