Find an array of size N having exactly K subarrays with sum S | C ++ program to find array with K subarrays with sum S ; Function to find array with K subarrays with sum S ; Driver Code ; Function call
#include <bits/stdc++.h> NEW_LINE using namespace std ; void SubarraysWithSumS ( int n , int k , int s ) { for ( int i = 0 ; i < k ; i ++ ) cout << s << " ▁ " ; for ( int i = k ; i < n ; i ++ ) cout << s + 1 << " ▁ " ; } int main ( ) { int n = 4 , k = 2 , s = 3 ; SubarraysWithSumS ( n , k , s ) ; return 0 ; }