Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions AUGUST LONG CHALLENGE/FifthSolution_CHEFWED.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include<bits/stdc++.h>
using namespace std;

int main()
{

int t;
cin>>t;

while(t--)
{
int n,k;
cin>>n>>k;

if(k==1)
{
int hash[101];
memset(hash,0,sizeof(hash));
int count=1;
int temp;
for(int i=0;i<n;i++)
{
cin>>temp;
if(hash[temp]<1)
hash[temp]++;
else
{
count++;
memset(hash,0,sizeof(hash));
hash[temp]++;
}
}


cout<<count<<endl;
}
}
}

38 changes: 38 additions & 0 deletions AUGUST LONG CHALLENGE/FirstSolution_CHEFWARS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

/* Name of the class has to be "Main" only if the class is public. */
class codechef1
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while(tc-- > 0)
{
int health = sc.nextInt();
int power = sc.nextInt();

while(true)
{
health = health - power;
power = power/2;

if(health <= 0)
{
System.out.println(1);
break;
}else if(power <= 0)
{
System.out.println(0);
break;
}
}
}
}
}

71 changes: 71 additions & 0 deletions AUGUST LONG CHALLENGE/FourthSolution_AUG20B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include<bits/stdc++.h>
using namespace std;


int main()
{

int tc;
cin>>tc;

string se,p;
vector<char> x;
int j=0,flag,z;

while(tc--)
{
j=0,z=0;
flag=0;
cin>>se>>p;
int hash[26]={0};
if(se.length()==1)
{
cout<<se;
}
else
{
for(int i=0;i<se.length();i++)
hash[(int)se[i]-97]++;

for(int i=0;i<p.length();i++)
hash[(int)p[i]-97]--;

vector<char> x;

for(int i=0;i<26;i++)
for(int j=0;j<hash[i];j++)
x.push_back((char)(i+97));

while(p[z+1]==p[z])
{
z++;
}
x.push_back(p[0]);
sort(x.begin(),x.end());

for(auto i=x.begin();i!=x.end();++i)
{
if(p[z+1]>p[z])
{
if(*i==p[0] && *(i+1)!=*i)
{
cout<<p;
}
else
cout<<*i;
}
else
{
if(*i==p[0] && flag==0)
{
cout<<p;
flag=1;
}
else
cout<<*i;
}
}
cout<<"\n";
}
}
}
44 changes: 44 additions & 0 deletions AUGUST LONG CHALLENGE/SecondSolution_LINCHESS.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
while(tc --> 0)
{
int n = sc.nextInt();
int k = sc.nextInt();
int cnt=0;
int min=9999999;
int val,result=0;
int [] arr = new int[n];
for(int i=0;i<n;++i)
arr[i]=sc.nextInt();
for(int i=0;i<n;++i)
{
if(k%arr[i]==0)
{
val = k/arr[i];
if(val<min)
{
min=val;
result = arr[i];
++cnt;
}
}
}
if(cnt==0)
System.out.println(-1);
else
System.out.println(result);
}
}
}

46 changes: 46 additions & 0 deletions AUGUST LONG CHALLENGE/ThirdSolution_CRDGAME3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/* Name of the class has to be "Main" only if the class is public. */
class codechef3
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();

while(tc --> 0)
{
int p1=0;
int p2=0;
int c = sc.nextInt();
int r = sc.nextInt();

if(c<=9)
p1=1;
else
{
p1 = c/9;
if(c%9!=0)
p1=p1+1;
}
if(r<=9)
p2=1;
else
{
p2 = r/9;
if(r%9!=0)
p2=p2+1;
}
if(p1<p2)
System.out.println("0" + " " + p1);
else
System.out.println("1" + " " + p2);

}
}
}