Search code examples
cruntime-error

codeforces runtime error on pset 1A


I am trying to solve problem 1A on codeforces

but i keep getting Test: #1, time: 0 ms., memory: 1828 KB, exit code: 1, checker exit code: 0, verdict: RUNTIME_ERROR you can check my entry here and find my code below , i tried to to run the program locally and it works fine and it passed the test case on the website

#include<stdio.h>
int calculateSquare(int n , int m , int a){
int length=0;
int width = 0;
if(n%a != 0){
    length = (n/a)+1 ;
}
else{
    length = n/a ;
}
 if(m%a != 0){
    width = (m/a)+1 ;
}
else{
    width = m/a ;
}

return length*width ;


 }
 void main(){
int n,m,a ;

scanf("%d %d %d",&n,&m,&a);
int output = calculateSquare(n,m,a);
printf("%d",output);
}

Solution

    • int calculateSquare(int n , int m , int a)

    return type is int and return value is length*width

    In the worst case a would be 1 and n, m would be 109 as stated in the problem

    Input

    The input contains three positive integer numbers in the first line: n,  m and a (1 ≤  n, m, a ≤ 109).

    So the return type int cannot hold the returned value for such case.

    Better using long long int if the compilation is conform with C99 standard.