dimanche 7 février 2021

All the testcases for this code is not passing. Can you say me how can I obtain it?

QUESTION: A circle of radius R cm is touching both the positive axes i.e., the X-axis and the Y-axis. There is another circle touching both the axes as well as the previous circle. Note that this circle won't have the same center as the original circle. The question is to find the sum of squares of the radius of all the circles that satisfies the condition.

#include<stdio.h>
#include<math.h>
int roundNo(double num) 
{ 
    return (num -(int)num) < 0.5 ? (int)num : ((int)num )+ 1; 
} 

int main() {
    int t;
    scanf("%d",&t);
   double multiplier1 = 2*sqrt(2)+3;
   double multiplier2 = 1/multiplier1;
    for(int i=0;i<t;i++){
        int n;
        scanf("%d",&n);
        double sum = (2 + multiplier1*multiplier1 + multiplier2*multiplier2)*n*n;
        printf("%d\n",roundNo(sum));
    }
}

Aucun commentaire:

Enregistrer un commentaire