Represent N as sum of K odd numbers with repetitions allowed | C ++ implementation to represent N as sum of K even numbers ; Function to print the representation ; N must be greater than equal to 2 * K and must be odd ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; void sumOddNumbers ( int N , int K ) { int check = N - ( K - 1 ) ; if ( check > 0 && check % 2 == 1 ) { for ( int i = 0 ; i < K - 1 ; i ++ ) { cout << "1 ▁ " ; } cout << check ; } else cout << " - 1" ; } int main ( ) { int N = 5 ; int K = 3 ; sumOddNumbers ( N , K ) ; return 0 ; }