Today is Chef's birthday. His mom gifted him a truly lovable gift, a permutation of first N positive integers.
She placed the permutation on a very long table in front of Chef and left it for him to play with it. But as there was a lot of people coming and wishing him. It was interfering with his game which made him very angry and he banged the table very hard due to which K numbers from the permutation fell down and went missing.
Seeing her son's gift being spoilt, his mom became very sad. Chef didn't want his mom to be sad as he loves her the most. So to make her happy, he decided to play a game with her with the remaining N - Knumbers on the table. Chef wants his mom to win all the games.
Chef and his mom play alternatively and optimally. In Xth move, a player can choose some numbers out of all the numbers available on the table such that chosen numbers sum up to X. After the move, Chosen numbers are placed back on the table.The player who is not able to make a move loses.
Now, Chef has to decide who should move first so that his Mom wins the game.
As Chef is a small child, he needs your help to decide who should move first. Please help him, he has promised to share his birthday cake with you :)
For each test case, print "Chef" if chef should move first otherwise print "Mom" (without quotes).
Input 2 5 2 3 5 5 1 1 Output Mom Chef
For test case 1.
So,Chef loses and Mom wins.
http://www.codechef.com/problems/CLPERM
#include<iostream> #include<algorithm> #include<string> #include<map> #include<vector> #include<cmath> #include<string.h> #include<stdlib.h> #include<cstdio> #include <ctime> #include <cstdlib> #define ll long long #define mod 998244353 using namespace std; ll x[10000001]; int main(){ int t; cin>>t; while(t--){ ll n,m,a; cin>>n>>m; for(int i=0;i<m;++i) cin>>x[i]; sort(x,x+m); ll p=0,s=0,u=0; for(int i=0;i<m;++i){ p+=x[i]; s=x[i]*(x[i]+1)/2-p; //最大能到达的数=总和-所有前面不出现的数字 if(x[i]>s){ s=x[i]-1; u=1; break; } } if(u==0) s=n*(n+1)/2-p; if(s%2==0) cout<<"Chef"<<endl; else cout<<"Mom"<<endl; } return 0; }