Why wrong answer for http://www.devskill.com/CodingProblems/

Dev Skill archived problems can be discussed here.

Why wrong answer for http://www.devskill.com/CodingProblems/

by smunchi » Sat Dec 17, 2016 1:44 am

Code: Select all
#include<stdio.h>
void main()
{
   int testCases, i, j, sum;
   long long int data[1000][1000];
   long long int avg;
    scanf("%d",&testCases);

    for (i = 0; i<testCases; i++) {
      for(j = 0; j<1; j++) {
         scanf("\n%lld %lld", &data[i][j], &data[i][j+1]);
      }
    }

    for (i = 0; i<testCases; i++) {
      for(j = 0; j<1; j++) {
         sum = data[i][j] + data[i][j+1];
         avg = sum/2;
         printf("%lld\n", avg);
      }
    }
}
 
Posts: 2
Joined: Sat Dec 17, 2016 1:37 am

Re: Why wrong answer for http://www.devskill.com/CodingProbl

by mahrahat » Wed Dec 21, 2016 3:36 am

First, there is no link to the problem!
Second, type of data is long long int but type of sum is int :
Code: Select all
sum = data[i][j] + data[i][j+1];

Third, even declaring sum as long long int does not work here!!!

You may check this
Lets
• search through previous topics before posting a new topic
• include link to problem (or at least problem number)
• write code snippets inside [code] [ /code] tags
 
Posts: 48
Joined: Thu Nov 24, 2016 9:11 pm
Location: Bangladesh

Re: Why wrong answer for http://www.devskill.com/CodingProbl

by smunchi » Wed Dec 21, 2016 12:55 pm

Thanks for the useful information. Yes, this one is DEVSKILL Victory Day 2016 Contest problem no 1: Hall of fames of JU.
 
Posts: 2
Joined: Sat Dec 17, 2016 1:37 am


Who is online
Users browsing this forum: No registered users and 1 guest
cron