Question Name:Little Deepu and his Girlfriend

#include<bits/stdc++.h>
 
using namespace std;
 
int n,m,s[10009];
bool game[10009];
 
int main()
{
    int tests;
	cin >> tests;
	while(tests--)
	{
		cin >> n >> m;
		int s[m];
		for(int i=0;i<m;i++) cin >> s[i];
		fill(game,game+n+1, false);
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<m;j++)
			{
				if(i<s[j])
					continue;
				else if(game[i-s[j]] == false)
				{
					game[i] = true;					
					break;
				}
			}
		}
		if (game[n])
			cout<<"Little Deepu\n";
		else
			cout<<"Kate\n";
	}
    return 0;
}
  • Problem Description
    Little Deepu recently got a new job, so to celebrate, he decided to take his girfriend, Kate, out on a fancy candle light dinner. 
    To make things perfect for Kate, Deepu planned the night to the last detail. The food, the music, the ambience, everything was perfect, but stupidly enough Deepu forgot to get her a present. 

    After dinner, Kate asks our Deepu for her gift, when she finds out that he hasn’t got her any she gets upset, to try smooth things with her, he proposes a game, this makes Kate so angry that she dumps him right there(bad move Deepu). Well its safe to say the rest of the evening was uneventful for Little Deepu but the game he proposed was pretty interesting.

    To put the game a bit formally, we have two players Little Deepu and Kate and M items in the bag B, also we have a game set S with N elements, each element of game set is an integer. 

    The game is played as follows, each player takes turn to pick an element from the game set S and removes that number of items from the bag, the player that is unable to remove the items from the bag looses the game. Little Deepu start the game ,If both Little Deepu and Kate play the game optimally, your task is to determine who wins the game. 

    Input:
    First line contains a integer T , number of test cases. Each test case contain two lines , first line contain two integer M and N and second line contain elements of S.

    Output:
    For each test case print name of the winner of the game .

    Constraints:
    1<=T <= 1000
    1 <= M <= 10000
    1 <= N <= 100
    1 <= S[i] <= M
  • Test Case 1
    Input (stdin)2
    3 2
    1 2
    5 3
    1 2 3
    Expected OutputKate
    Little Deepu
  • Test Case 2
    Input (stdin)3
    3 3
    2 1 4
    4 2
    1 2
    4 3
    2 6 1

    Expected OutputKate
    Little Deepu
    Little Deepu

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro