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
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
- 1 ≤ T ≤ 1000
- 1 ≤ salary ≤ 100000
Example
Input 3 1203 10042 1312 Output 2406 20383.2 2624
My Solution:
- #include
- int main()
- {
- int x;
- float Salary;
- scanf("%d",&x);
- while(x--)
- {
- double GrossSalary=0;
- scanf("%f",&Salary);
- if(Salary>1500)
- {
- GrossSalary= Salary+500+.98*Salary;
- }
- else
- {
- GrossSalary= Salary+.1*Salary+.9*Salary;
- }
- printf("%g\n",GrossSalary);
- }
- 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.
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
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:
- import java.util.*;
- class ChefandDolls {
- public static void main(String args[])
- {
- Scanner in=new Scanner(System.in);
- int b=in.nextInt();
- while(b-->0)
- {
- long N=in.nextLong();
- long arr[]=new long[(int)N];
- int i;
- for(int j=0;j
) - {
- arr[j]=in.nextInt();
- }
- Arrays.sort(arr);
- for(i=0;i
1;) - {
- if((i+1
1)){ - if((arr[i]!=arr[i+1]))
- {
- break;
- }
- else
- {
- i=i+2;
- }
- }
- }
- System.out.println(arr[i]);
- }
- }
}
Comments
Post a Comment