Skip to content

Commit c61cc47

Browse files
Added CodeChef problems
1 parent 388f7a7 commit c61cc47

File tree

5 files changed

+259
-0
lines changed

5 files changed

+259
-0
lines changed

CodeChef/Correct Sentence.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// Question CODE: CORTSENT
2+
// Question: https://www.codechef.com/START4C/problems/CORTSENT
3+
/* Input:
4+
3
5+
1 aN
6+
2 ab NO
7+
3 A N D
8+
*/
9+
/* Output:
10+
NO
11+
YES
12+
NO
13+
*/
14+
15+
#include <bits/stdc++.h>
16+
#define l long
17+
#define ll long long
18+
using namespace std;
19+
20+
set <int> s;
21+
int x=0;
22+
int main()
23+
{
24+
ios_base :: sync_with_stdio(false);
25+
cin.tie(NULL);
26+
cout.tie(NULL);
27+
28+
bool nigg = true;
29+
int t;
30+
cin >> t;
31+
while(t--){
32+
nigg=true;
33+
int k;
34+
cin >> k;
35+
for(int j=0;j<k;j++){
36+
string s;
37+
cin >> s;
38+
bool capslo=false,small=false;
39+
40+
if(nigg==true){
41+
for(int i=0;i<s.length();i++){
42+
if(s[i] >= 'a' && s[i] <= 'z'){
43+
if(s[i] >= 'n' && s[i] <= 'z')
44+
{
45+
nigg = false;
46+
break;
47+
}
48+
else
49+
{
50+
small=true;
51+
if(capslo == true){
52+
nigg=false;
53+
break;
54+
}
55+
}
56+
}
57+
58+
if(s[i] >= 'A' && s[i] <= 'Z'){
59+
if(s[i] <= 'M')
60+
{
61+
nigg =false;
62+
break;
63+
}
64+
else
65+
{
66+
capslo=true;
67+
if(small == true){
68+
nigg=false;
69+
break;
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}
76+
if(nigg) cout << "YES";
77+
else cout << "NO";
78+
cout << "\n";
79+
80+
}
81+
82+
return 0;
83+
}

CodeChef/Cricket Ranking.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Question CODE: CRICRANK
2+
// Question: https://www.codechef.com/START6C/problems/CRICRANK
3+
/* Input:
4+
3
5+
0 1 2
6+
2 3 4
7+
10 10 10
8+
8 8 8
9+
10 0 10
10+
0 10 0
11+
*/
12+
/* Output:
13+
B
14+
A
15+
A
16+
*/
17+
18+
#include<bits/stdc++.h>
19+
using namespace std;
20+
#define ll long long int
21+
int main()
22+
{
23+
ll t;
24+
cin>>t;
25+
while(t--)
26+
{
27+
ll r1,r2,w1,w2,c1,c2,count1=0,count2=0;
28+
cin>>r1>>w1>>c1;
29+
cin>>r2>>w2>>c2;
30+
if(r1>=r2)
31+
{
32+
count1++;
33+
}
34+
else
35+
{
36+
count2++;
37+
}
38+
if(w1>=w2)
39+
{
40+
count1++;
41+
}
42+
else{
43+
count2++;
44+
}
45+
if(c1>=c2)
46+
{
47+
count1++;
48+
}
49+
else{
50+
count2++;
51+
}
52+
if(count1>=count2)
53+
{
54+
cout<<"A"<<endl;
55+
}
56+
else
57+
{
58+
cout<<"B"<<endl;
59+
}
60+
}
61+
return 0;
62+
}

CodeChef/Factorial.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Question CODE: FCTRL
2+
// Question: https://www.codechef.com/LRNDSA01/problems/FCTRL
3+
/* Input:
4+
6
5+
3
6+
60
7+
100
8+
1024
9+
23456
10+
8735373
11+
*/
12+
/* Output:
13+
0
14+
14
15+
24
16+
253
17+
5861
18+
2183837
19+
*/
20+
21+
#include <iostream>
22+
using namespace std;
23+
24+
int main() {
25+
int t;
26+
cin>>t;
27+
long long int n,zeros;
28+
while(t--)
29+
{
30+
zeros = 0;
31+
cin>>n;
32+
long long int x;
33+
while(n>4)
34+
{
35+
x = n/5;
36+
zeros+=x;
37+
n = x;
38+
}
39+
cout<<zeros<<endl;
40+
}
41+
return 0;
42+
}

CodeChef/Hoop Jump.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Question CODE: HOOPS
2+
// Question: https://www.codechef.com/LTIME96C/problems/HOOPS
3+
/* Input:
4+
2
5+
1
6+
3
7+
*/
8+
/* Output:
9+
1
10+
2
11+
*/
12+
13+
#include <bits/stdc++.h>
14+
using namespace std;
15+
#define ll long long
16+
int main()
17+
{
18+
ll t;
19+
cin>>t;
20+
while(t--)
21+
{
22+
ll n;
23+
cin>>n;
24+
if(n==1)
25+
{
26+
cout<<n<<endl;
27+
}
28+
else
29+
{
30+
cout<<(n/2)+1<<endl;
31+
}
32+
}
33+
return 0;
34+
}

CodeChef/Three Dices.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Question CODE: THREDICE
2+
// Question: https://www.codechef.com/START6C/problems/THREDICE
3+
/* Input:
4+
3
5+
1 3
6+
2 4
7+
2 3
8+
*/
9+
/* Output:
10+
0.333333
11+
0
12+
0.166666
13+
*/
14+
15+
#include<bits/stdc++.h>
16+
using namespace std;
17+
#define ll long long int
18+
#define ld long double
19+
int main()
20+
{
21+
ll t;
22+
cin>>t;
23+
int ar[]={1,2,3,4,5,6};
24+
while(t--)
25+
{
26+
int a,b,count=0,i=5;
27+
cin>>a>>b;
28+
int res=a+b;
29+
while(ar[i]-res>0)
30+
{
31+
count++;
32+
i--;
33+
}
34+
double ans=(double)count/6.0;
35+
cout<<ans<<endl;
36+
}
37+
return 0;
38+
}

0 commit comments

Comments
 (0)