Marbles Question in Mathematics category competetive porgramming course

https://hack.codingblocks.com/contests/c/384/759
This is question and this is my code why this is uncorrect?

#include<bits/stdc++.h>
using namespace std;
unsigned long long tavan(int a,int b){
    if(b==0)return 1;
    unsigned long long result=tavan(a,b/2);
    result *=result;
    if(b&1){
        result=result*a;
    }
    return result;
}
int main() {
  int t;cin >> t;
  for(int i=0;i<t;++i){
    int k,n;cin >> k >> n;
    unsigned long long res=0;
    res=tavan(k,n-k);cout << res << endl;
  }
	return 0;
}

here the approach used doesn’t seem to be correct…you have to divide n marbles into k groups such that that every group has at least one. This is a very standard problem in pnc. You can solve it using stars and bars technique.

What is stars and bars technique?

You have to find out C(n-1,k-1) here…


watch this for more about stars and bars