# Codechef June Challenge

Complete : Chef and Subarray

Complete : Guessing Game

## 4 thoughts on “Codechef June Challenge”

1. I dunno why but it says timelimit exceeded for guessing game. I am not using bruteforce for finding the result but for reducing it to irreducable fraction… seems they have a lot of load right now

Like

2. I presume that you are using brute force method for finding the Irreducible fraction, so I stress this link. Read on and I am promising that you will find a faster algorithm to find the irreducible fraction.
If not, i think you are correct. Try after some time.
I am struggling too hard for third one 😦

Like

3. now thanks to gcd function I dont get that error still it says incorrent. The thing is I feel there is something worng with type of i/o that my program gives. Can you please check the code and tell if its a logical fault or fault with my i/o (if it is with i/o please tell the correct way)…

#include
#include

using namespace std;
unsigned int hcf(unsigned long a, unsigned long b) {
if (b == 0) {
return a;
} else {
return hcf(b, a % b);
}
}
int main()
{
// freopen(“out.txt”,”w”,stdout);
// freopen(“in.txt”,”r”,stdin);
unsigned long T,N[100000],M[100000],i,j,no,ne,mo,me,n1,n2,k;
cin>>T;
for(i=0;i>N[i]>>M[i];
for(i=0;i<T;i++)
{
no = ne = N[i]/2;
if(N[i]%2!=0) no++;
mo = me = M[i]/2;
if(M[i]%2!=0) mo++;
n1 = ne*mo + no*me;
n2 = N[i]*M[i];
do
{
k = hcf(n1,n2);
n1/=k;
n2/=k;
}while(k!=1);
cout<<n1<<"/"<<n2<<endl;
}
}

Like