Untitled
unknown
plain_text
2 years ago
570 B
6
Indexable
#include<bits/stdc++.h> using namespace std; int decimal(long int s) { int dec=0, n=0, rem=0; while(s!=0) { rem = s%10; s/=10; dec+= rem*pow(2,n); n++; } return dec; } int returrn(long int x, long int n) { int c; for(int i=1; i<=n; i++) { int p=(2/pow(2,i)); c= x^p; } if(c>x){ return c; } } int main() { long int t, i, n, p,x, s; cin>>t; while(t--) { cin>>n>>s; x= decimal(s); cout<<returrn(x,n)<<endl; } return 0; }
Editor is loading...