Division 3 Codchef April Long Challenge Solutions
Valid Pair Problem Code: SOCKS1
Link of Problem : https://www.codechef.com/APRIL21C/problems/SOCKS1
C++ :
#include <iostream>
using namespace std;
int main() {
int a,b,c;
cin>>a>>b>>c;
if(a==b||b==c||c==a)
cout<<"YES";
else cout<<"NO";
return 0;
}
World Record Problem Code: BOLT
Problem Link : https://www.codechef.com/APRIL21C/problems/BOLT
Python :
for _ in range(int(input())):
k1,k2,k3,v = list(map(float, input().split()))
l = round((100/(k1*k2*k3*v)),2)
if l < 9.58:
#print(l)
print("YES")
else:
#print(l)
print("NO")
Strong Language Problem Code: SSCRIPT
Problem Link : https://www.codechef.com/APRIL21C/problems/SSCRIPT
Python :
for _ in range(int(input())):
n,k = list(map(int, input().split()))
cnt=0;max=0
s = input()
for i in range(n):
if s[i]=='*':
cnt+=1
if(cnt>=max): max = cnt
else: cnt=0
if max>=k:
print("YES")
else:
print("NO")
C++ :
#include <iostream>
using namespace std;
int main() {
int t,n,k;
string s;
cin>>t;
while(t--){
cin>>n>>k;
cin>>s;
int c=0, max=0;
for(int i=0; i<n; i++){
if(s[i]=='*'){
c+=1;
if(c>=max)
max=c;
}
else c=0;
}
if(max>=k) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
Chef and Dice Problem Code: SDICE
Problem Link : https://www.codechef.com/APRIL21C/problems/SDICE
Python :
for _ in range(int(input())):
s = [0, 20, 36, 51, 60]
n = int(input())
if n<=4:
print(s[n])
else:
r = n%4
a = ((n-r)//4)*44
p = [16, 32, 44, 55]
print(p[r]+a)
Worthy Matrix Problem Code: KAVGMAT
Problem link : https://www.codechef.com/APRIL21C/problems/KAVGMAT
Note : The below solution is under maintenance, we have to work on else part of it for 2X2 matrix. If anyone knows why we not getting appropriate output, then pls either comment down in this blog or comment on the any video of TECH_ED channel. Link down below.
C++ :
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(long long int i = a; i < b; i++)
typedef long long int ll;
int main() {
int t; cin>>t;
while(t--)
{
ll n,m,k, v=0, l=0, s=0;;
double avg;
cin>>n>>m>>k;
ll a[n][m], md = min(m,n);
f(i,0,n)
{
f(j,0,m) cin>>a[i][j];
}
while(l<md){
l++;
if(l==1){
f(i,0,n){
f(j,0,m){
if(a[i][j]>=k)
v+=1;
}
}
}
else
f(i,0,n-1){
f(j,0,m-1){
f(y,j,j+1){
f(x,i,i+1){
s+=a[x][y];
}
}
avg = (double)s/(l*l);
if(avg>=k){
v+=m-l+1-j;
break;
}
}
}
}
cout<<v<<endl;
}
return 0;
}
If you like my solutions pls do a favour :
Search "TECH_ED" on youtube and subscribe :pray:
OR
If you feel lazy for that click here to subscribe :