codechef program #29 : Gross Salary ;codechef program #30: Chef and Dolls




FLOW011










Problem Statement #1
In a company an emplopyee is paid as under: If his basic salary is less than Rs. 1500, then HRA = 10% of base salary and DA = 90% of basic salary.
If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic salary. If the Employee's salary is input, write a program to find his gross salary.

NOTE: Gross Salary = Basic Salary+HRA+DA

Input

The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer salary.

Output

Output the gross salary of the employee.

Constraints

  •  T  1000
  •  salary  100000

Example

Input

3 
1203
10042
1312

Output

2406
20383.2
2624



My Solution:
  1. #include 
  2.  
  3.  
  4.   int main()
  5.   {
  6.   int x;
  7.   float Salary;
  8.   scanf("%d",&x);
  9.   while(x--)
  10.   {
  11.  
  12.     double GrossSalary=0;
  13.    scanf("%f",&Salary);
  14.                         if(Salary>1500)
  15.                         {
  16.                         GrossSalary=  Salary+500+.98*Salary;
  17.                         }
  18.                         else
  19.                         {
  20.                         GrossSalary=  Salary+.1*Salary+.9*Salary; 
  21.                         }
  22.                         printf("%g\n",GrossSalary);
  23.   }
  24.   return 0;




Problem Statement #2



Chef is fan of pairs and he likes all things that come in pairs. He even has a doll collection in which all dolls have paired.One day while going through his collection he found that there are odd number of dolls. Someone had stolen a doll!!!
Help chef find which type of doll is missing..

Input

The first line contains the number of test cases.
Second line of the input contains the number of elements in the array.
The next n lines are the types of each doll that is left.

Output

Find the type of doll that doesn't have a pair

Constraints

1<=T<=10
1<=N<=100000 (10^5)
1<=ti<=100000
Input:
1
3
1 
2
1


Output:
2
Input:
1
5
1
1
2
2
3
Output:
3







My Solution:

  1. import java.util.*;
  2.  
  3.  
  4. class ChefandDolls {
  5.         public static void main(String args[])
  6.         {
  7.         Scanner in=new Scanner(System.in);
  8.         int b=in.nextInt();
  9.         while(b-->0)
  10.         {
  11.                         long N=in.nextLong();
  12.                         long arr[]=new long[(int)N];
  13.                         int i;
  14.  
  15.                         for(int j=0;j)
  16.                                         {
  17.                        
  18.                                         arr[j]=in.nextInt();
  19.                                         }
  20.                        
  21.  
  22.                         Arrays.sort(arr);
  23.                        
  24.                         for(i=0;i1;)
  25.                         {
  26.                                         if((i+11)){
  27.                                         if((arr[i]!=arr[i+1]))
  28.                                                         {
  29.                                                         break;
  30.                                                         }
  31.                                         else
  32.                                         {
  33.                                                         i=i+2;
  34.                                         }
  35.                                         }
  36.                                        
  37.                         }
  38.                         System.out.println(arr[i]);
  39.         }
  40.         }

}


 Posted by Lol ik.



Comments

Popular Posts