title: Number Ways Node Make Loop Size K Undirected Complete Connected Graph N Nodes
signature: class Solution {
  
      public float NumberWaysNodeMakeLoopSizeKUndirectedCompleteConnectedGraphNNodes(int n, int k) {
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(float actual, float expected){
              return Math.Abs(actual - expected) < 1e-06f;
          }
  
          public string driver(int n, int k, float expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                float pred_result = solution_cls.PLACEHOLDER_FN_NAME(n, k); 
                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(
                  16, 2, 
                  15.0f
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );
          }
      }
  }
  
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;
  }