title: Count Distinct Non Negative Pairs X Y Satisfy Inequality Xx Yy N 2 1
signature: fun countDistinctNonNegativePairsXYSatisfyInequalityXxYyN21(n: Int): Int {
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;
  }
question_info.test_list: [{"idx": 0, "outputs": 64, "inputs": {"n": 72}}, {"idx": 1, "outputs": 69, "inputs": {"n": 75}}, {"idx": 2, "outputs": 83, "inputs": {"n": 92}}, {"idx": 3, "outputs": 30, "inputs": {"n": 30}}, {"idx": 4, "outputs": 41, "inputs": {"n": 45}}, {"idx": 5, "outputs": 37, "inputs": {"n": 40}}, {"idx": 6, "outputs": 71, "inputs": {"n": 81}}, {"idx": 7, "outputs": 17, "inputs": {"n": 17}}, {"idx": 8, "outputs": 71, "inputs": {"n": 81}}, {"idx": 9, "outputs": 86, "inputs": {"n": 99}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(72, 64)
      println("TEST-0...${result}")
      
      result = driver(75, 69)
      println("TEST-1...${result}")
      
      result = driver(92, 83)
      println("TEST-2...${result}")
      
      result = driver(30, 30)
      println("TEST-3...${result}")
      
      result = driver(45, 41)
      println("TEST-4...${result}")
      
      result = driver(40, 37)
      println("TEST-5...${result}")
      
      result = driver(81, 71)
      println("TEST-6...${result}")
      
      result = driver(17, 17)
      println("TEST-7...${result}")
      
      result = driver(81, 71)
      println("TEST-8...${result}")
      
      result = driver(99, 86)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: countDistinctNonNegativePairsXYSatisfyInequalityXxYyN21
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn