title: Count Distinct Non Negative Pairs X Y Satisfy Inequality Xx Yy N 2 1
signature: class Solution {
  
      public int CountDistinctNonNegativePairsXYSatisfyInequalityXxYyN21(int n) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(int actual, int expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(int n, int expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                int pred_result = solution_cls.PLACEHOLDER_FN_NAME(n); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  72, 
                  64
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  75, 
                  69
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  92, 
                  83
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  30, 
                  30
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  45, 
                  41
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  40, 
                  37
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  81, 
                  71
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  17, 
                  17
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  81, 
                  71
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  99, 
                  86
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
source_py: def count_distinct_non_negative_pairs_x_y_satisfy_inequality_xx_yy_n_2_1(n):
      x = 0
      res = 0
      yCount = 0
      while ((yCount * yCount) < n):
          yCount = (yCount + 1)
      while (yCount != 0):
          res = (res + yCount)
          x = (x + 1)
          while ((yCount != 0) and (((x * x) + ((yCount - 1) * (yCount - 1))) >= n)):
              yCount = (yCount - 1)
      return res
source_cpp: int count_distinct_non_negative_pairs_x_y_satisfy_inequality_xx_yy_n_2_1(int n) {
    int x = 0, yCount, res = 0;
    for ( yCount = 0;
    yCount * yCount < n;
    yCount ++ );
    while ( yCount != 0 ) {
      res += yCount;
      x ++;
      while ( yCount != 0 && ( x * x + ( yCount - 1 ) * ( yCount - 1 ) >= n ) ) yCount --;
    }
    return res;
  }