Numerical Ability
1.
Krishna purchases 50 dozen eggs at Rs. 4 per dozen. Of these, 40 eggs were found broken. At what
price should he sell the remaining eggs in order to make a profit of 5%?
Rs. 1.5/dozen
Rs. 2.5/dozen
Rs. 3.5/dozen
Rs. 4.5/dozen
Reasoning Ability
Verbal Ability
Technical Mcq
Programming
1.
Problem statement
You are given a string S consisting of lowercase alphabets. A good subsequence of this string is a
subsequence which contains distinct characters only. Determine the number of good subsequences of
the maximum possible length modulo 10^9 +7. In other words, determine the length X of the longest
good subsequence and the number of good subsequences of length X modulo 10^9 +7.
Input Format
• First line: An integer T denoting the number of test cases
• Each of the next T lines: String S
Constraints
1<T < 10
1<|S|<10^5
Output Format
For each test case, print the number of good subsequences of the maximum length modulo 10^9 +7.
Answer for each test case should come in a new line.
Sample Input:
7
ncdadbmhjfkl
mfijdmeebmed
hcbmgjpdcime
fjpkbjpijcjd
jhbcolmnfmp
C CODE:
#include <stdio.h>
int main(){
long long int t,n,i,m=1000000007;
scanf("%lld",&t);
while(t--){
char a[100000];
long long int h[26]={0},f=1;
scanf("%s",a);
n=strlen(a);
for(i=0;i<n;i++){
h[a[i]-'a']++;
}
for(i=0;i<26;i++){
if(h[i]>0){
f=((f%m)*(h[i]%m))%m;
}
}printf("%lld\n",f);
}
}
2.
Problem statement
Creatnx now wants to decorate his house by flower pots. He plans to buy exactly N ones. He can only
buy them from Triracle's shop. There are only two kind of flower pots available in that shop. The shop is
very strange. If you buy X flower pots of kind 1 then you must pay A x X^2 and B x Y^2? if you buy Y
flower pots of kind 2. Please help Creatnx buys exactly N flower pots that minimizes money he pays.
Input Format
The first line contains a integer T denoting the number of test cases.
Each of test case is described in a single line containing three space-separated integers N, A, B.
Constraints
•1<T < 10^5
•1<N, A, B < 10^5
Output Format
For each test case, print a single line containing the answer.
Sample Input;
2
5 1 2
10 2 4
Sample Output:
17
134
C++ CODE:
#define ll long long int
using namespace std;
int main()
{
ll t; cin>>t; while(t--)
{
ll n,a,b;
cin>>n>>a>>b;
ll k=(b*n)/(a+b);
ll x=(a*k*k) + (b*(n-k)*(n-k));
k++;
ll y=(a*k*k) + (b*(n-k)*(n-k));
cout<<min(x,y)<<endl;
}
}________________________________________________________
Post a Comment