text: Find K numbers with sum equal to N and sum of their squares maximized | C # program to find K numbers with sum equal to N and the sum of their squares maximized ; Function that prints the required K numbers ; Print 1 , K - 1 times ; Print ( N - K + 1 ) ; Driver code
code: using System ; class GFG { static void printKNumbers ( int N , int K ) { for ( int i = 0 ; i < K - 1 ; i ++ ) Console . Write ( 1 + " ▁ " ) ; Console . Write ( N - K + 1 ) ; } public static void Main ( String [ ] args ) { int N = 10 , K = 3 ; printKNumbers ( N , K ) ; } }