Challenge : JULY21; Problem Code: XXOORR

Couldn’t able to find a Test Case where my code is not working. Please help me to find where my code is not working also the issue with my approach.

Code:

#include
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;

int Dec2Bin(lli D2B)
{
if (D2B == 0)
return 0;
else
return (D2B % 2 + 10 * Dec2Bin(D2B / 2));
}

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);

#ifndef ONLINE_JUDGE
//for getting input from input.txt
freopen(“input.txt”, “r”, stdin);
//for writing output to output.txt
freopen(“output.txt”, “w”, stdout);
#endif

lli TC;
lli N, K;
cin >> TC;

while (TC --)
{
	cin >> N >> K;
	lli i, Ar, Arr[N];
	lli Sum, Rem, Ans = 0;

	for (i = 0; i < N; i++)
	{
		cin >> Arr[i];

		Ar = Arr[i];
		Ar = Dec2Bin(Ar);
		Arr[i] = Ar;
	}

	Sum = accumulate(Arr, Arr + N, 0);
	cout << Sum << "\n";

	while (Sum != 0)
	{
		Rem = Sum % 10;
		if (Rem == 1)
		{
			Ans = Ans + 1;;
		}
		else
		{
			if (Rem % K == 0)
				Ans = Ans + (Rem / K);
			else
				Ans = Ans + ((Rem / K) + 1);
		}
		Sum = Sum / 10;
	}
	cout << Ans << "\n";
}
return 0;

}

Thank You, in Advance.

Didn’t go in details of your main function.
But your Dec2Bin function won’t return correct conversion from decimal to binary.

Ex- D2B=1000000000
Number of digits in binary conversion of D2B will be log_2 1000000000 which is 30 digits.
No data type can store such a big number.