title: Number Ways Node Make Loop Size K Undirected Complete Connected Graph N Nodes
signature: float numberWaysNodeMakeLoopSizeKUndirectedCompleteConnectedGraphNNodes(int n, int k) {
test_code: #include <algorithm>
  #include <assert.h>
  #include <cstdlib>
  #include <iostream>
  #include <map>
  #include <set>
  #include <string>
  #include <tuple> 
  #include <unordered_map>
  #include <vector>
  #include <math.h>
  #include <cmath>
  #include <bits/stdc++.h>
  #include <numeric>
  #include <functional>
  
  using namespace std;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(float actual, float expected){
      return abs(actual - expected) < 1e-06;
  }
  
  string driver(int n, int k, float expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n, k), expected)){
              return "PASSED";
          }
          return "FAILED";
      }
      catch (const std::overflow_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::runtime_error& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (const std::exception& exception_obj)
      {
          return typeid(exception_obj).name();
      }
      catch (...)
      {
          return "UNK_ERROR";
      }
  }
  
  int main() {
      string result = "";
  
      result = driver(16, 2, 15.0); 
      cout << "TEST-" << 0 << "..."
           <<  result
           << "\n";
  
      return 0;
  }
source_py: def number_ways_node_make_loop_size_k_undirected_complete_connected_graph_n_nodes(n, k):
      p = 1
      if (k % 2):
          p = (- 1)
      return ((pow((n - 1), k) + (p * (n - 1))) / n)
source_cpp: int number_ways_node_make_loop_size_k_undirected_complete_connected_graph_n_nodes(int n, int k) {
    int p = 1;
    if ( k % 2 ) p = - 1;
    return ( pow ( n - 1, k ) + p * ( n - 1 ) ) / n;
  }