GUDDU AND HIS DATE

can anybody please help me
i got when i gave input 2019 it showed correct answer but when i submitted it showed verdict as wrong answer the following below is code written by me in c language
#include<stdio.h>
#include<math.h>
void absdig(int m){
int a[1000000],i = 0;
int count = 0,y,product = 1,r = 1000000007,g;
while( m != 0){
y = m % 10;
m = m / 10;
a[i] = y;
count++;
i++;
}
for(int j = 0;j < count;j++){
for(int k = 0;k < j;k++){
g = fabs(a[k] - a[j]);
product *= g % r;
}
}
printf("%d\n",product % r);
product = 1;
count = 0;
}

int main(){
int m,t;
scanf("%d",&t);
while(t){
scanf("%d",&m);
absdig(m);
t–;
}
return 0;
}

See e.g. What's Wrong with this Code, who posted just a little while before you did :slight_smile:

2 Likes

When I gave the given testcase as input it showed correct answer but when I submitted it showed wrong answer

How can u take input as integer…!!!
Read problem constraints carefully…
Input number can have 10^6 digits and integer can hold only 32 bits i.e. at max 10 digits.
Due to integer overflow you are getting wrong answer.
So, take input as a string.
Check it: whats-wrong-with-this-code

1 Like