osipyonok

Untitled

May 19th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define INF 1000010000
  6. #define nl '\n'
  7. typedef long long ll;
  8.  
  9. ll gcd(ll a, ll b) {
  10.     return b ? gcd(b, a % b) : abs(a);
  11. }
  12.  
  13. ll lcm(ll a, ll b) {
  14.     return abs( a / gcd(a, b) * b );
  15. }
  16.  
  17. string DecToBin(int n){
  18.     string ans = "";
  19.     while(n != 0){
  20.         ans = ((n % 2)?"1":"0") + ans;
  21.         n/=2;
  22.     }
  23.     return ans;
  24. }
  25.  
  26. int main() {
  27.     ios_base::sync_with_stdio(false);
  28.     cin.tie(NULL);
  29.     cout.precision(0);
  30.     int n;
  31.     cin >> n;
  32.     string str = DecToBin(n);
  33.     for( int i = 1 ; i < str.length() ; ++i )
  34.         cout << "S" << ( str[i] == '1' ? "X" : "");
  35.     return 0;
  36. }
Add Comment
Please, Sign In to add comment