Advertisement
fooker

Untitled

Sep 29th, 2022
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int binomialcoeff(int n, int k)
  4. {
  5. if (k > n)
  6. return 0;
  7. if ((k == 0) || (k == n))
  8. return 1;
  9. return binomialcoeff(n - 1, k - 1)
  10. + binomialcoeff(n - 1, k);
  11. }
  12.  
  13. int main()
  14. {
  15. int t;
  16. cin>>t;
  17. while (t--){
  18. int n;
  19. cin>>n;
  20. int player = (n/2);
  21. if (n==2){
  22. cout<<"1"<<" "<<"0"<<" "<<"1"<<"\n";
  23. }
  24. if (n==4){
  25. cout<<"3"<<" "<<"2"<<" "<<"1"<<"\n";
  26. }
  27. if (n>4){
  28. int n_1, n_2, n_3, recur;
  29. n_3=1;
  30. recur = 0;
  31. for (int i=0; player-3-i>0; i++){
  32. recur = recur + binomialcoeff(n-4-4i, player-3-i) + binomialcoeff(n-5-4i, player-3-i);
  33. }
  34. n_1= binomialcoeff(n-1, player-1)+ recur;
  35. n_2=binomialcoeff(n, player) - n_1 - n_3;
  36. cout<<(n_1 % 998244353)<<" "<<(n_2 % 998244353)<<" "<<(n_3 % 998244353)<<"\n";
  37. }
  38. }
  39.  
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement