Why do i get wrong

Hey … i need help for this code
If I run this code on my desktop , I get true answer but Here, I am getting wrong answer.

#include<iostream>
#include<stdio.h>
#define gc getchar_unlocked
using namespace std;
int main()
{
int ct=0,n;
long int k,t;
cin>>n>>k;
for(int i=0;i<n;i++)
{
	t=gc();
	if((t%k)==0)
		ct++;
}
printf("%d",ct);
cout<<endl;
return 0;
} 

Question code : INTEST

getchar_unlocked() reads only one character from input. Not complete integer like what you are expected to do in this particular question.

You can use scanf() or use this function to read the integers faster…

int get_int()
{
int num = 0;
char c = getchar_unlocked();
    while(!(c>='0' && c<='9'))
        c = getchar_unlocked();
while(c>='0' && c<='9')
{
	num = (num<<1)+(num<<3)+c-'0';
	c=getchar_unlocked();
}
return num;
}

and can call the function when needed like t=get_int()

1 Like