Chef and Socks Codechef Solution

Chef and Socks Codechef Solution: Today, Chef woke up to find that he had no clean socks. Doing laundry is such a turn-off for Chef, that in such a situation, he always buys new socks instead of cleaning the old dirty ones. He arrived at the fashion store with money rupees in his pocket and started looking for socks. Everything looked good, but then Chef saw a new jacket which cost jacketCost rupees. The jacket was so nice that he could not stop himself from buying it.

Interestingly, the shop only stocks one kind of socks, enabling them to take the unsual route of selling single socks, instead of the more common way of selling in pairs. Each of the socks costs sockCost rupees.

Chef bought as many socks as he could with his remaining money. It’s guaranteed that the shop has more socks than Chef can buy. But now, he is interested in the question: will there be a day when he will have only 1 clean sock, if he uses a pair of socks each day starting tommorow? If such an unlucky day exists, output “Unlucky Chef”, otherwise output “Lucky Chef”. Remember that Chef never cleans or reuses any socks used once.

Input

The first line of input contains three integers — jacketCost, sockCost, money — denoting the cost of a jacket, cost of a single sock, and the initial amount of money Chef has, respectively.

Output

In a single line, output “Unlucky Chef” if such a day exists. Otherwise, output “Lucky Chef”.

Constraints

  • 1 ≤ jacketCost ≤ money ≤ 109
  • 1 ≤ sockCost ≤ 109

Example

Input:
1 2 3
Output:
Unlucky Chef
Input:
1 2 6
Output:
Lucky Chef

Chef and Socks CodeChef Solution in JAVA

/* 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
	{
		try {
		   Scanner sc  =  new Scanner(System.in);
		        long jacketPrice = sc.nextLong();
		long socksPrice = sc.nextLong();
		long money = sc.nextLong();
		long pairOfSocks = ((money-jacketPrice)/socksPrice);
		if(pairOfSocks % 2 == 0){
		    System.out.println("Lucky Chef");
		}
		else{
		    System.out.println("Unlucky Chef");
		}
		} catch(Exception e)
		{
		    return;
		}
	}
}

Chef and Socks CodeChef Solution in CPP

#include <bits/stdc++.h>
using namespace std;
int main(){
        int j,s,m,ans;
        cin>>j>>s>>m;
        ans=(m-j)/s;
        if(ans%2==0){
            cout<<"Lucky Chef"<<endl;
        }
        else{
            cout<<"Unlucky Chef"<<endl;
        }
  return 0;
}

Chef and Socks CodeChef Solution in Python

x,y,z=map(int,input().split())
p=z-x
p=p//y
if(p%2==0):
    print("Lucky Chef")
else:
    print("Unlucky Chef")
    

Disclaimer: The above Problem (Chef and Socks) is generated by CodeChef but the solution is provided by Chase2learn.This tutorial is only for Educational and Learning purpose.

Sharing Is Caring