4 Particles Codevita 9 Solution

4 Particles Codevita 9 Solution

Description 
 
There is a 3D square of stature H, and there are 4 moving particles on the vertical edges of the 3D shape. At first particles are at some stature A, B, C and D individually. These particles are moving various way (Only upward or descending, no sideways development) with various speed. 
 
In the event that the molecule is moving upward or descending arrives at the tip of the shape then it stay at the tip just and won’t move further. On the off chance that different particles have not arrive at the tip they keep on moving along their individual edges their separate way till the last molecule arrives at the tip. 
 
These 4 particles will make two triangles in a 3-D plane. Since the particles are moving, entirety of the region of these two triangles will change each second. 
 
Discover the most extreme and least of the whole of the zones of these two triangles. 
Allude the Examples segment for better understanding. 
 
Requirements 
  • 1 <= H <= 100 
  • 0 <= A, B, C, D <= H 
  • 0 <= V1, V2, V3, V4 <= 100 
 
 
Information 
  • First line contains a whole number H which indicates the length of the side of 3D shape. 
  • Second line contains 4 space isolated whole numbers indicating the underlying situation of each of the 4 particles on the 4 vertical edges, state A, B, C and D separately. 
  • Third line contains 4 space isolated numbers meaning the speed everything being equal, say V1, V2, V3, and V4 per time unit individually. 
  • Fourth line contains 4 space isolated characters U or D meaning the heading of development of particles. U signifies the upward bearing and D means the descending heading. 
 
Yield 
 
Print 2 space isolated numbers which mean the worth 
 
[4 * [Max (aggregate of territory of triangle ABC and zone of triangle ADC)]2] and 
 
[4 * [Min (aggregate of territory of triangle ABC and zone of triangle ADC)]2] 
 
separately. On the off chance that the above qualities are decimal incentive adjust them to closest whole number. 
 
Time Limit 
 
 
Models 
 
Model 1 
 
Info 
 
10 
 
 
 
U D 
 
 
Yield 
 
80000 40000 
 
Clarification 
 
The development per time unit is delineated as appeared in the charts beneath. 
 
Note: Within an express the territory of whole of triangle ABC and triangle ADC is steady. The MAXAREA and MINAREA terms utilized in the graphs above are utilized to monitor greatest region and least zone accomplished until that point in time. 
 
MAXAREA = [4 * [Max (aggregate of region of triangle ABC and zone of triangle ADC)]2] 
 
MINAREA = [4 * [Min (aggregate of region of triangle ABC and zone of triangle ADC)]2] 
 
Model 2 
 
Info 
 
10 
 
 
1 2 1 2 
 
D U D 
 
Yield 
 
80000 40000 
 
Clarification 
 
The development per time unit is delineated as appeared in the charts beneath. 
 
Note: Within an express the zone of aggregate of triangle ABC and triangle ADC is consistent. The MAXAREA and MINAREA terms utilized in the outlines above are utilized to monitor most extreme region and least territory accomplished until that point in time. 
 
MAXAREA = [4 * [Max (total of zone of triangle ABC and region of triangle ADC)]2 
 
MINAREA = [4 * [Min (total of zone of triangle ABC and region of triangle ADC)]2] 
 
Model 3 
 
Information 
 
10 
 
 
 
U D U D 
 
Yield 
 
120000 40000 
 
Clarification 
 
The development per time unit is portrayed as appeared in the outlines underneath. 
 
Note: Within an express the zone of aggregate of triangle ABC and triangle ADC is consistent. The MAXAREA and MINAREA terms utilized in the outlines above are utilized to monitor most extreme region and least territory accomplished until that point in time. 
 
MAXAREA = [4 * [Max (total of zone of triangle ABC and region of triangle ADC)]2] 
 
MINAREA = [4 * [Min (total of zone of triangle ABC and region of triangle ADC)]2]
 
 

Codevita Season 9 All Questions Solutions

Listed Here :

1 thought on “4 Particles Codevita 9 Solution”

  1. import java.util.*;
    public class Cubical {
    static int[] initialpos=new int[4];
    static int[] currentpos=new int[4];
    static int[] speed=new int[4];
    static char[] direction=new char[4];
    static boolean [] reachedend=new boolean[4];static int height=0;
    static boolean timerrunning=true;static int timer=0;static double currentarea, max=0,min=0;
    public static void main(String args[]){
    for(int i=0;i<4;i++) reachedend[i]=false;//initialize the status as false.

    Scanner sc=new Scanner(System.in);
    height=sc.nextInt();
    for(int a=0;a<4;a++){
    initialpos[a]=sc.nextInt();
    }
    for(int a=0;a<4;a++){
    speed[a]=sc.nextInt();
    }
    sc.nextLine();int i=0;
    String directions=sc.nextLine();
    //tested input till here.
    //extract the chars.
    for(char ch:directions.toCharArray())
    {
    if(ch!=' ')
    {
    direction[i]=ch;i++;
    }
    }
    //all input tested and done.

    while(timerrunning){timer++;
    currentpos=getpos(timer);
    currentarea=getarea(currentpos);
    if(timer==1){
    max=currentarea;
    min=currentarea;

    }
    if(timer>1)
    {
    if(min>currentarea)min=currentarea;
    if(max=height)){
    currentpos[i]=initialpos[i]+speed[i]*timer;

    }else {
    currentpos[i]=height;reachedend[i]=true;
    }

    }
    if(direction[i]=='D'){
    if(!((initialpos[i]-speed[i]*timer)<=0)){
    currentpos[i]=initialpos[i]-speed[i]*timer;

    }else {
    currentpos[i]=0;reachedend[i]=true;
    }
    }
    }
    pos=currentpos;
    return pos;
    }
    //getpos function is tested verbally.

    public static double getarea(int pos[]){
    double area=0;
    double a,b,c,d,s1,s2,s3,s4,s5;
    a=pos[0];
    b=pos[1];
    c=pos[2];
    d=pos[3];
    s1=Math.sqrt(Math.pow(a-b, 2)+height*height);
    s2=Math.sqrt(Math.pow(b-c, 2)+height*height);
    s3=Math.sqrt(Math.pow(c-d, 2)+height*height);
    s4=Math.sqrt(Math.pow(d-a, 2)+height*height);
    s5=Math.sqrt(Math.pow(b-d, 2)+2*height*height);
    double p1=(s1+s4+s5)/2;double area1=Math.sqrt(p1*(p1-s1)*(p1-s4)*(p1-s5));
    double p2=(s2+s3+s5)/2; double area2=Math.sqrt(p2*(p2-s2)*(p2-s3)*(p2-s5));

    area=area1+area2;

    return area;
    }

    static void p(String s){

    System.out.println(s);

    }

    }

    Reply

Leave a Comment

close
error: Content is protected !!
Free Udemy Courses and Hacking Resources Join Us on TelegramClick Here
+