# Card Game || Codeforces Educational Round 136 Div2 Problem C

Newton School’s ๐ ๐ฎ๐ฅ๐ฅ ๐๐ญ๐๐๐ค ๐๐จ๐ฎ๐ซ๐ฌ๐ ๐๐๐๐ –

Newton School Official WhatsApp Support Number: +91 6362 331 200

———————————————————————————–

๐๐๐๐ฅ๐๐ ๐ซ๐๐ฆ:

๐๐๐ข๐ง๐ค๐๐๐๐ง: …

๐๐๐ง๐ฌ๐ญ๐๐ ๐ซ๐๐ฆ: …

๐๐
๐๐๐๐๐จ๐จ๐ค:

——– ๐๐๐จ๐ฎ๐ญ ๐๐๐ฐ๐ญ๐จ๐ง ๐๐๐ก๐จ๐จ๐ฅ ——–

๐ตNEWTON SCHOOL is an online Edtech company providing the highest-rated FULL STACK DEVELOPMENT PROGRAM for professionals, graduates, and women.

๐NEWTON SCHOOL is your gateway to a high-paying tech career in 6 months with Zero fees till placement, transforming you into a rockstar full-stack developer earning 5-40 Lakh per annum salary. Newton Schoolโs students are already working in more than 150+ top companies of India including Zomato, Unacademy, Deloitte, Nutanix, etc.

๐ตTo watch more videos on programming, Data Structures, Android Development, Data Science, C++, Java, React, subscribe to our channel.

– – – – – – – – – – – – – –

If you’re reading this far down, hello, you look nice today ๐

Card Game || Codeforces Educational Round 136 Div2 Problem C

#NewtonSchool #NS #Fullstack #FSD #Datascience #MS #Postgrad #webdeveloper #programming #programmer #programmers #developer #coder #programmingmemes #coders #coding #frontenddeveloper #backenddeveloper #html #softwaredeveloper #hacking #python

Thank you brother:)

why have you done n-1Cn/2 when we have picked nth element for alex so it should be n-1Cn/2 -1

What is the expected rating of this problem?

Thank You very much for the editorial. Full supportโค

can you plz provide code?

can you please upload the editorial of Reset K Edges problem

๐

bro wt resource did u use to learn combinatorics topics.

Thank youuuu

Thanks for editorial.

but suppose , borris has the nth card and alex has the ( n – 1 ) th card , and its alex turn . now the question is why would he waste his ( n – 1 )th card knowing that the orther person already has the

n th card , instead he would try to make borris waste his nth card in the beginning itself by using ( n – 2 )nd or ( n – 3 )rd card and then when his turn comes , so he plays the ( n – 1 )th card and win th e game .

are they bound to use the maximum card they have ? , is that the exact statement they should have inserted ?

why we didn't need of memoization ?

nice explanation bhaiya thank you

thank you sir

can number of ways alex has the (nth card) cant be equal to n-1 choose (n/2)-1

i was thinking of Bitwise DP, can it be possible with that ?

i have a doubt in my code my code gives ans for <=56 but for 58 and 60 due to mod i think it giving wrong ans??

Good explanation ๐

I got all the observations that you have got, but failed at implementation(taking alex equivalent to boris or viceversa)

Can u suggest some more problems like this.

Nice explanation ๐

Dp means??

Great explanation for such a complex question๐

what is that ncr thing that you did in the code , how can i learn that , is that some efficiient approach to deal with factorial things , thank you sir

nice explanation mate

idk why but this is failing on n=60

#include <bits/stdc++.h>

using namespace std;

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

#define all(x) (x).begin(),(x).end()

//#define loop(i,n) for(int i=0; i<n ;i++)

typedef pair<int,int> ppi;

typedef vector<int> vi;

typedef vector<vector<int>> vvi;

// #define mod 998244353

int fact(int n){

if(n==0) return 1;

return n*fact(n-1);

}

int c(int n,int r){

if(n<r) return 0;

if(r == 0 || r==n) return 1;

return (fact(n))/fact(n-r) / fact(r);

}

void fun(int n , vvi &dp){

if(n==2) return;

fun(n-2,dp);

dp[n][0] = (c(n-1 , n/2) + dp[n-2][1] )% 998244353 ;

dp[n][1] = ( c(n-2 , n/2) + dp[n-2][0])% 998244353;

dp[n][2] = (dp[n-2][2])% 998244353;

}

signed main(){

FastIO

//cout<<fixed<<setprecision(10);

int z;

cin>>z;

while(z–){

int n;

cin>>n;

//is A have nth card he wins

//similarly is B have nth card plus (n-2)th card B wins

//else draw

vvi dp (n+1 , vector<int> (3,-1));

//as n is greater than 1

//base cases

dp[2][0] = 1;

dp[2][1] = 0;

dp[2][2] = 1;

fun(n,dp);

cout<<dp[n][0]<<" "<<dp[n][1]<<" "<<dp[n][2];

cout<<endl;

}

return 0;

}

great explanation sir!

please can you share the entire code. I am not getting the correct answer for n=60. I couldn't understand how you defined Invfact[ ] and modInverse( ) ๐ฅฒ

Thanku and Hare krishna Sir ๐๐

nice explanation

i did not understand the base case can you explain if possible