Skip to content

Commit 4199840

Browse files
author
Kiran Patil
authored
Add files via upload
1 parent b813fc3 commit 4199840

37 files changed

Lines changed: 876 additions & 0 deletions

AlternateAddition.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Alternate Additions Problem Code: ALTERADDSolvedSubmit
2+
// Chef has 2 numbers A and B (A<B).
3+
4+
// Chef will perform some operations on A.
5+
6+
// In the ith operation:
7+
8+
// Chef will add 1 to A if i is odd.
9+
// Chef will add 2 to A if i is even.
10+
// Chef can stop at any instant. Can Chef make A equal to B?
11+
12+
// Input Format
13+
// The first line contains a single integer T — the number of test cases. Then the test cases follow.
14+
// The first and only line of each test case contains two space separated integers A and B.
15+
// Output Format
16+
// For each test case, output YES if Chef can make A and B equal, NO otherwise.
17+
18+
// Note that the checker is case-insensitive. So, YES, Yes, yEs are all considered same.
19+
20+
// Constraints
21+
// 1≤T≤1000
22+
// 1≤A<B≤109
23+
// Sample Input 1
24+
// 4
25+
// 1 2
26+
// 3 6
27+
// 4 9
28+
// 10 20
29+
// Sample Output 1
30+
// YES
31+
// YES
32+
// NO
33+
// YES
34+
// Explanation
35+
// Test case 1: Chef may perform one operation to make A equal to B: 1−→+12
36+
// Test case 2: 3−→+14−→+26
37+
// Test case 3: It can be shown that it is impossible to make A and B equal.
38+
39+
// Test case 4: 10−→+111−→+213−→+114−→+216−→+117−→+219−→+120
40+
#include <iostream>
41+
using namespace std;
42+
43+
int main() {
44+
int t;
45+
cin>>t;
46+
while(t--)
47+
{
48+
int x,y;
49+
cin>>x>>y;
50+
if((y-x)%3==0)
51+
cout<<"YES"<<endl;
52+
else if((y-x)%3!=0 and (y-x)%3==1)
53+
cout<<"YES"<<endl;
54+
else
55+
cout<<"NO"<<endl;
56+
}
57+
58+
// your code goes here
59+
return 0;
60+
}

AlternateAddition.exe

44.1 KB
Binary file not shown.

Bergers.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Problem
2+
// Chef is fond of burgers and decided to make as many burgers as possible.
3+
4+
// Chef has AA patties and BB buns. To make 11 burger, Chef needs 11 patty and 11 bun.
5+
// Find the maximum number of burgers that Chef can make.
6+
7+
// Input Format
8+
// The first line of input will contain an integer TT — the number of test cases. The description of TT test cases follows.
9+
// The first and only line of each test case contains two space-separated integers AA and BB, the number of patties and buns respectively.
10+
// Output Format
11+
// For each test case, output the maximum number of burgers that Chef can make.
12+
13+
// Constraints
14+
// 1 \leq T \leq 10001≤T≤1000
15+
// 1 \leq A, B \leq 10^51≤A,B≤10
16+
// 5
17+
18+
// Sample 1:
19+
// Input
20+
// Output
21+
// 4
22+
// 2 2
23+
// 2 3
24+
// 3 2
25+
// 23 17
26+
// 2
27+
// 2
28+
// 2
29+
// 17
30+
// Explanation:
31+
// Test case 11: Chef has 22 patties and 22 buns, and therefore Chef can make 22 burgers.
32+
33+
// Test case 22: Chef has 22 patties and 33 buns. Chef can make at most 22 burgers by using 22 patties and 22 buns.
34+
35+
// Test case 33: Chef has 33 patties and 22 buns. Chef can make at most 22 burgers by using 22 patties and 22 buns.
36+
37+
// Test case 44: Chef has 2323 patties and 1717 buns. Chef can make at most 1717 burgers by using 1717 patties and 1717 buns.
38+
#include <iostream>
39+
using namespace std;
40+
41+
int main() {
42+
int t;
43+
cin>>t;
44+
while(t--)
45+
{
46+
int x,y;
47+
cin>>x>>y;
48+
if(x<=y)
49+
cout<<x<<endl;
50+
else if(x==y)
51+
cout<<x<<endl;
52+
else
53+
cout<<y<<endl;
54+
}
55+
// your code goes here
56+
return 0;
57+
}

Bergers.exe

44 KB
Binary file not shown.

ChairsRequirement.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Chef's coding class is very famous in Chefland.
2+
3+
// This year X students joined his class and each student will require one chair to sit on. Chef already has Y chairs in his class. Determine the minimum number of new chairs Chef must buy so that every student is able to get one chair to sit on.
4+
5+
// Input Format
6+
// The first line contains a single integer T — the number of test cases. Then the test cases follow.
7+
// The first and only line of each test case contains two integers X and Y — the number of students in the class and the number of chairs Chef already has.
8+
// Output Format
9+
// For each test case, output the minimum number of extra chairs Chef must buy so that every student gets one chair.
10+
11+
// Constraints
12+
// 1≤T≤1000
13+
// 0≤X,Y≤100
14+
// Sample Input 1
15+
// 4
16+
// 20 14
17+
// 41 41
18+
// 35 0
19+
// 50 100
20+
// Sample Output 1
21+
// 6
22+
// 0
23+
// 35
24+
// 0
25+
// Explanation
26+
// Test case 1: There are 20 students in the class and Chef has 14 chairs already. Therefore Chef must buy 6 more chairs.
27+
// Test case 2: There are 41 students in the class and Chef already has exactly 41 chairs. Therefore Chef does not need to buy any more chairs.
28+
// Test case 3: There are 35 students in the class and Chef has no chairs initially. Therefore Chef must buy 35 chairs.
29+
#include <iostream>
30+
using namespace std;
31+
32+
int main() {
33+
int t;
34+
cin>>t;
35+
while(t--)
36+
{
37+
int x,y;
38+
cin>>x>>y;
39+
if(x>=y)
40+
cout<<(x-y)<<endl;
41+
else
42+
cout<<"0"<<endl;
43+
}
44+
// your code goes here
45+
return 0;
46+
}

ChairsRequirement.exe

44.2 KB
Binary file not shown.

CntACS.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <iostream>
2+
using namespace std;
3+
4+
int main() {
5+
int t;
6+
cin>>t;
7+
while(t--)
8+
{
9+
int pt;
10+
cin>>pt;
11+
if(pt>=100){
12+
if(pt%100<=(10-(pt/100)))
13+
cout<<((pt%100)+(pt/100))<<endl;
14+
else
15+
cout<<"-1"<<endl;
16+
}
17+
else{
18+
if(pt<=10)
19+
cout<<pt<<endl;
20+
else
21+
cout<<"-1"<<endl;
22+
}
23+
}
24+
// your code goes here
25+
return 0;
26+
}

CntACS.exe

44.3 KB
Binary file not shown.

ComplimentToDNA.class

1.44 KB
Binary file not shown.

ComplimentToDNA.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import java.util.*;
2+
import java.lang.*;
3+
import java.io.*;
4+
5+
/* Name of the class has to be "Main" only if the class is public. */
6+
class ComplimentToDNA
7+
{
8+
public static void main (String[] args) throws java.lang.Exception
9+
{
10+
Scanner s = new Scanner(System.in);
11+
int t=s.nextInt();
12+
while(t-->0)
13+
{
14+
int n=s.nextInt();
15+
String str=s.next();
16+
String ans="";
17+
for(int i=0;i<n;i++)
18+
{
19+
if(str.charAt(i)=='T'){
20+
ans+='A';
21+
}
22+
else if(str.charAt(i)=='A'){
23+
ans+='T';
24+
}
25+
else if(str.charAt(i)=='G'){
26+
ans+='C';
27+
}
28+
else{
29+
ans+='G';
30+
}
31+
}
32+
System.out.println(ans);
33+
}
34+
// your code goes here
35+
}
36+
}

0 commit comments

Comments
 (0)