!! FIRST NO WHICH CANT BE FORMED !!
THERE IS A SET OF NUMBERS U NEED TO FIND FIRST NO WHICH CANT BE FORMEND
BY USING THAT NUMBER ..
EX
LET 3 AND 5 IS MISSING FROM INFINITE SET OF INTEGER ..
THAN
1 CAN BE FORMED
2 CAN BE FORMED
3 CAN BE FORMED(1+2) SINCE 1 AND 2 IS PRESENT
4 CAN BE FORMED
5 CAN BE FORMED
6 CAN BE FORMED (4+2)
7 CAN BE FORMED(1+2+4)
8 CANT FORMED
#################################EDITORIAL#####################
#################################CODE##################################
THERE IS A SET OF NUMBERS U NEED TO FIND FIRST NO WHICH CANT BE FORMEND
BY USING THAT NUMBER ..
EX
LET 3 AND 5 IS MISSING FROM INFINITE SET OF INTEGER ..
THAN
1 CAN BE FORMED
2 CAN BE FORMED
3 CAN BE FORMED(1+2) SINCE 1 AND 2 IS PRESENT
4 CAN BE FORMED
5 CAN BE FORMED
6 CAN BE FORMED (4+2)
7 CAN BE FORMED(1+2+4)
8 CANT FORMED
#################################EDITORIAL#####################
#################################CODE##################################
- #include<iostream>
- using namespace std;
- #include<algorithm>
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- long long int m,n;
- cin>>n>>m; // WHARE M IS MAXIMUM VALUED NO IN SET AND M IS NO OF NUMBERS MISSING
- long long int arr[m];
- for(int i=0;i<m;i++)// READING MISSING NOS
- cin>>arr[i];
- sort(arr,arr+m);
- int sum=0,f=0;
- for(int i=0;i<m;i++)
- {
- sum+=arr[i];
- if(arr[i]*(arr[i]+1)/2-sum<arr[i])
- {
- if(arr[i]%2==1) cout<<"Chef\n";
- else
- cout<<"Mom\n";
- // cout<<arr[i]<<endl;
- f=1;
- break;
- }
- }
- if(f==0)
- {
- if((n*(n+1)/2-sum)%2==0) cout<<"Chef\n";
- else
- cout<<"Mom\n";
- }
- }
- return 0;
- }
No comments:
Post a Comment