fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <map>
  4. #include <set>
  5. #include <cmath>
  6. #include <vector>
  7. #include <climits>
  8. #include <string>
  9. #include <algorithm>
  10. #include <sstream>
  11. #include <numeric>
  12. using namespace std;
  13.  
  14. vector<string> split(string haystack, string needle) {
  15. vector<string> result;
  16. int startPos = 0;
  17. int foundPos = haystack.find(needle, startPos);
  18. while (foundPos != string::npos) {
  19. int count = foundPos - startPos;
  20. string token = haystack.substr(startPos, count);
  21. if (!token.empty()) {
  22. result.push_back(token);
  23. }
  24. startPos = foundPos + needle.length();
  25. foundPos = haystack.find(needle, startPos);
  26. }
  27. string token = haystack.substr(startPos, haystack.length() - startPos);
  28. if (!token.empty()) {
  29. result.push_back(token);
  30. }
  31. return result;
  32. }
  33.  
  34. string nameConvert(const string& name) {
  35. const string DELIMITER = " ";
  36. stringstream builder;
  37. auto parts = split(name, DELIMITER);
  38. for (auto part : parts) {
  39. part[0] = toupper(part[0]);
  40. transform(part.begin() + 1, part.end(), part.begin() + 1, ::tolower);
  41. builder << part << DELIMITER;
  42. }
  43. return builder.str();
  44. }
  45.  
  46. string dateConvert(const string& date) {
  47. const string DELIMITER = "/";
  48. stringstream builder;
  49. auto parts = split(date, DELIMITER);
  50. builder << setw(2) << setfill('0') << parts[0] << DELIMITER;
  51. builder << setw(2) << setfill('0') << parts[1] << DELIMITER;
  52. builder << parts[2];
  53. return builder.str();
  54. }
  55.  
  56. void decimalToBinary(long long n) {
  57. if (n == 0) {
  58. return;
  59. }
  60. decimalToBinary(n / 2);
  61. cout << n % 2;
  62. }
  63. int main() {
  64. ios_base::sync_with_stdio(false);
  65. cin.tie(NULL);
  66.  
  67. long long n;cin >> n;
  68. if (n == 0) {
  69. cout << 0;
  70. return 0;
  71. }
  72. decimalToBinary(n);
  73. return 0;
  74. }
  75.  
Success #stdin #stdout 0s 5340KB
stdin
Standard input is empty
stdout
11111111111111000011101011010011001000011010000