# Help me in solving DAILY train problem

### My issue

cant understand question daily train

### My code

``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
}
}

``````

Problem Link: DAILY Problem - CodeChef

@anaqh
Its basically a maths problem , u have to count the number of ways in which all friends can have tickets in one compartment.
plzz refer my solution for better understanding of the logic.

``````#include <bits/stdc++.h>
using namespace std;

int main() {
int x,n;
cin>>x>>n;
map<int,int> mp;
mp[0]=1;
mp[1]=1;
mp[2]=2;
mp[3]=6;
mp[4]=24;
mp[5]=120;
mp[6]=720;
int ans=0;
while(n--)
{
string s;
cin>>s;
int cnt=0;
for(int i=0,j=53;i<j;i+=4,j-=2)
{
cnt=0;
for(int k=i;k<i+4;k++)
{
if(s[k]=='0')
cnt++;
}
if(s[j]=='0')
cnt++;
if(s[j-1]=='0')
{
cnt++;
}
if(cnt>=x)
{
ans+=mp[cnt]/(mp[x]*mp[cnt-x]);
}
}
// cout<<
}
cout<<ans;
return 0;
}
``````