title: Count Numbers Can Constructed Using Two Numbers
signature: func countNumbersCanConstructedUsingTwoNumbers(n int, x int, y int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(n int, x int, y int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n, x, y),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(23, 
  	16, 
  	16, 1)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(56, 
  	95, 
  	6, 9)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(30, 
  	63, 
  	1, 30)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(51, 
  	89, 
  	46, 1)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(21, 
  	99, 
  	38, 0)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(69, 
  	63, 
  	50, 2)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(12, 
  	69, 
  	73, 0)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(44, 
  	52, 
  	9, 4)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(99, 
  	65, 
  	10, 13)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(46, 
  	58, 
  	37, 1)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def count_numbers_can_constructed_using_two_numbers(n, x, y):
      arr = [False for i in range((n + 2))]
      if (x <= n):
          arr[x] = True
      if (y <= n):
          arr[y] = True
      result = 0
      for i in range(min(x, y), (n + 1)):
          if arr[i]:
              if ((i + x) <= n):
                  arr[(i + x)] = True
              if ((i + y) <= n):
                  arr[(i + y)] = True
              result = (result + 1)
      return result
source_cpp: int count_numbers_can_constructed_using_two_numbers(int n, int x, int y) {
    vector < bool > arr ( n + 1, false );
    if ( x <= n ) arr [ x ] = true;
    if ( y <= n ) arr [ y ] = true;
    int result = 0;
    for ( int i = min ( x, y );
    i <= n;
    i ++ ) {
      if ( arr [ i ] ) {
        if ( i + x <= n ) arr [ i + x ] = true;
        if ( i + y <= n ) arr [ i + y ] = true;
        result ++;
      }
    }
    return result;
  }