CM1904-Editorial

PROBLEM LINK:

Practice
Contest

Author: Manish
Tester: Neeraj
Editorialist: Sumit

DIFFICULTY:

MEDIUM.

PREREQUISITES:

Math, Bit-Masking.

PROBLEM:

Neeraj went on a trip to wonderland during his vacation. While visiting different places there he was hungry and decided to get a pizza for himself, he found a shop nearby and went there to buy a pizza. As he noticed a weird transaction style there in which you have to pay another amount that is mentioned in your bill.

The trend was like if the bill amount is, 0 -> 0 1 -> 0 2 -> 0 5 -> 4 12 -> 8.

SOLUTIONS:

Setter's Solution
#include <bits/stdc++.h>

using namespace std;
#define ll long long

signed main(){
ll t; cin>>t;
while(t–){
int n; cin>>n;
cout<<(n&(n-1))<<endl;
}
return 0;
}

Tester's Solution
Editorialist's Solution