Computer Science, asked by karthikasundar1805, 8 months ago

Max sum String pair Jogging ground Election Moving average codevita answers

Answers

Answered by ratheeshbaskaran7
65

Answer:

import java.util.*;

class Main  

{  

     

   static int  Divisors(int n)  

   { int co=0;

       for (int i=2;i<n;i++)  

       {    if (n%i==0)  

                 co++;

       }

       return co;

   

   }  

 

     

   public static void main(String args[])  

   {  

     

      Scanner sc=new Scanner(System.in);

      int a=sc.nextInt();int great=0,small=0;

      int b=sc.nextInt();

      if(a>=b)

        { great=a; small=b;}

       else

        { great=b; small=a;}

      int co1=0,co2=0;

      if(a==b)

         System.out.print("0");

     else if(a%b==0 || b%a==0)

      {  if(a<=b)

           co1=Divisors(a);

        else

           co2=Divisors(b);

        System.out.print(co1+co2+1);

         

     }

      else if(small*small<great)

      {

          co1=Divisors(a)+Divisors(b);

          System.out.print(co1-1);

      }

      else  

        {

            co1=Divisors(a)+Divisors(b);

            System.out.print(co1);

        }

   }      

}

Explanation:

Answered by yoyohapisingh1999
15

Answer:

String pair TCS Codevita

python3:

num2words = {1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', \

            6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten', \

           11: 'Eleven', 12: 'Twelve', 13: 'Thirteen', 14: 'Fourteen', \

           15: 'Fifteen', 16: 'Sixteen', 17: 'Seventeen', 18: 'Eighteen', \

           19: 'Nineteen', 20: 'Twenty', 30: 'Thirty', 40: 'Forty', \

           50: 'Fifty', 60: 'Sixty', 70: 'Seventy', 80: 'Eighty', \

           90: 'Ninety', 0: 'Zero'}

counter = 0

def getPairsCount(arr, n, summ):

     

   count = 0

   for i in range(0, n):

       for j in range(i + 1, n):

           if arr[i] + arr[j] == summ:

               count += 1

     

   return count

def countVowels(string):

   global counter

   vowels='aeiouAEIOU'

   v=[each for each in string if each in vowels]

   counter+=len(v)

   

def getWord(n):

   try:

       countVowels(num2words[n])

   except KeyError:

       try:

           countVowels(num2words[n-n%10] + num2words[n%10].lower())

       except KeyError:

           print('Number out of range')

   

ip=int(input())

numbers=input().split()

numbers = [int(i) for i in numbers]

for i in range(ip):

   getWord(numbers[i])

totalsum=counter

result=getPairsCount(numbers,ip,totalsum)

try:

   print(num2words[result])

except KeyError:

   try:

       print(num2words[result-result%10] + num2words[result%10].lower())

   except KeyError:

       print('Number out of range')

/////////////////////////////////

Zoo Design

import numpy as np

def largest(List):

   return max(List)

def smallest(List):

   return min(List)

TotalCost=0

animals=[]

costvalues=input().split()

costvalues = [int(i) for i in costvalues]

costvalues.sort()

areavalues=input().split()

areavalues = [int(i) for i in areavalues]

areavalues.sort()

herbivorous=input().split()

herbivorous = [int(i) for i in herbivorous]

animals.append(herbivorous)

carnivorus=input().split()

carnivorus = [int(i) for i in carnivorus]

animals.append(carnivorus)

aquatic=input().split()

aquatic = [int(i) for i in aquatic]

animals.append(aquatic)

totalSpace=int(input())

cost1=smallest(costvalues)*areavalues[costvalues.index(smallest(costvalues))]

cost2=largest(costvalues)*np.prod(animals[costvalues.index(largest(costvalues))])*areavalues[costvalues.index(largest(costvalues))]

   

resultSpace=totalSpace-(areavalues[costvalues.index(smallest(costvalues))]+(np.prod(animals[costvalues.index(largest(costvalues))])*areavalues[costvalues.index(largest(costvalues))]))

cost3=resultSpace*costvalues[costvalues.index(smallest(costvalues))+1]

TotalCost=cost1+cost2+cost3

print(TotalCost)

Explanation:

num2words is a dictionary

Similar questions