Skip to main content

Posts

Showing posts with the label sphere online judge

solution of -CIRCLE_E - Three Circle Problem (EASY) on spoj

solution- Given 3 distinct circles with positive integer radius  R1 ,  R2 , and  R3 , and arranged like in the picture below: Now, your task is to compute radius of small circle that can be created like yellow circle in the picture above. All circles in the picture above tangent each other. Input- The first line in the input data, there is an integer  T (0 <  T  ≤ 10 3 ) denoting number of test cases, than  T  lines follow. For each lines, there are three integer   R1 ,  R2 , and  R3 , (0 < { R1 , R2 , R3 } < 10 9 ) denoting radius of each circle like in the picture above. ATTENTION- take input in float- SYNTAX- #include<stdio.h> #include<math.h> #include<stdlib.h> int main() {double a,b,c,t; double r; scanf("%lf",&t); while(t--) { scanf("%lf%lf%lf",&a,&b,&c); if(a>0&&b>0&&c>0) { r=a*b*c/(2*sqrt(a*b*c*(a+b+...

solution of-BOMARBLE - D - Playing with Marbles on spoj

BOMARBLE - D - Playing with Marbles Pablo was assigned in his class to construct pentagons inside pentagons with marbles but he doesn’t know how many marbles he will need. He knows that for one pentagon he needs 5 marbles The only way he knows to insert a second pentagon is putting a marble in the middle of each segment and drawing three lines as shown. He puts a marble in the intersecting lines and removes them. To insert a third pentagon inside he first divides all segments in two including the ones that are not needed, and repeats the procedure. Drawing a second pentagon will require 12 marbles. A third pentagon will require 22 marbles. Given the information of how many pentagons will be created, write a program to calculate the number of marbles needed. solution- #include<stdio.h> int main() {int n,k; while(scanf("%d",&n)!=EOF) { if(n==0) break; else { k=5*n+((n-1)*(3*n-2))/2; printf("%d\n",k); } ...