My solution is here: CodeChef: Practical coding for everyone
Can anyone explain, why is my solution wrong?
I have seen other’s accepted solution. The logic is same.
Please help me out!!
My solution is here: CodeChef: Practical coding for everyone
Can anyone explain, why is my solution wrong?
I have seen other’s accepted solution. The logic is same.
Please help me out!!
You were not printing string for different test cases in different lines. You forgot to use print(end="\n") after each test case loop.
Because you are not printing the answer on newline.
Updated Source-Code:
t = int(input().strip())
for _ in range(t):
n, k = map(int, input().strip().split())
li = list(map(int, input().strip().split()))
for i in li:
if i % k == 0:
print("1", end = "")
else:
print("0", end = "")
print()
newline missing for every test case
Thank you!!
you forgot to add print() after the end of for loop
#include
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
long long int n,k;
cin>>n>>k;
long long int d[n];
for(int i=0;i<n;i++)
{
cin>>d[i];
if(d[i]%k==0)
cout<<1;
else
cout<<0;
}
cout<<endl;
}
return 0;
}
plz tell error of my code plzz its giving tle
Format your code first as the forum software has messed it up.