Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int binomialcoeff(int n, int k)
- {
- if (k > n)
- return 0;
- if ((k == 0) || (k == n))
- return 1;
- return binomialcoeff(n - 1, k - 1)
- + binomialcoeff(n - 1, k);
- }
- int main()
- {
- int t;
- cin>>t;
- while (t--){
- int n;
- cin>>n;
- int player = (n/2);
- if (n==2){
- cout<<"1"<<" "<<"0"<<" "<<"1"<<"\n";
- }
- if (n==4){
- cout<<"3"<<" "<<"2"<<" "<<"1"<<"\n";
- }
- if (n>4){
- int n_1, n_2, n_3, recur;
- n_3=1;
- recur = 0;
- for (int i=0; player-3-i>0; i++){
- recur = recur + binomialcoeff(n-4-4i, player-3-i) + binomialcoeff(n-5-4i, player-3-i);
- }
- n_1= binomialcoeff(n-1, player-1)+ recur;
- n_2=binomialcoeff(n, player) - n_1 - n_3;
- cout<<(n_1 % 998244353)<<" "<<(n_2 % 998244353)<<" "<<(n_3 % 998244353)<<"\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement