Advertisement
semsem_elazazy

https://codeforces.com/group/n3sTiYtHxI/contest/348734/problem/C

Feb 24th, 2022
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include<bits/stdc++.h>
  3. #define ll long long
  4. using namespace std;
  5.  
  6.  
  7. bool odd(int n ){
  8.     return n%2 ;
  9. }
  10.  
  11. string binary(int n ){
  12.     string bin ;
  13.     while (n>0){
  14.         bin.push_back(n%2 ==0 ?'0':'1');
  15.         n/=2;
  16.     }
  17.     reverse(bin.begin(),bin.end());
  18.     return bin;
  19. }
  20.  
  21. bool palindrome (string s){
  22.     int l=0 , r=s.size()-1;
  23.     while (l<r){
  24.         if (s[l++]!= s[r--])
  25.         return false;
  26.        
  27.         return true ;
  28.     }
  29. }
  30.  
  31. int main() {
  32.    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  33.  
  34.  
  35.  int n ; cin>>n;
  36.  
  37.  if(odd(n) && palindrome(binary(n)))  cout<<"YES\n";
  38.  else   cout <<"NO\n";
  39.  
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement