I posted it before, but it got closed, I hope I fixed it.
I wrote a solution in google kickstart 2021 round C "Aliens Generator" problem. The problem is that my solution works perfectly fine in the Code Blocks IDE, but the kickstart environment returns a runtime error when given the same set of input data. Google Kickstart platform didn't provide any message with the error.
Link to the problem: https://codingcompetitions.withgoogle.com/kickstart/round/0000000000435c44/00000000007ec1cb
My code in C:
#include<stdio.h>
int main(){
int T;
int G;
int x;
int y;
scanf("%d",&T);
for(x=1; x<=T; x++){
scanf("%d",&G);
y=1;
for(int k=1; k<G/2.0; k++){
if((2*k-1)*(2*k-1) + 8*G > 0 ){
float d = sqrt((2*k-1)*(2*k-1)+8*G);
if(d==floor(d) && (1-2*k+d)>0 && (1-2*k+(int)d)%2==0){
y++;
}
}
}
printf("Case #%d: %d\n", x, y);
}
return 1;
}
Input:
5
4
5
6
9
15
Related output obtained in the Code Blocks IDE:
Case#1: 1
Case#2: 2
Case#3: 2
Case#4: 3
Case#5: 4
The Kickstart platform returnes a Runtime Error with no messages.