fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. // Function to generate a string of a repeated character
  10. string generate_string(char ch, int count) {
  11. return string(count, ch);
  12. }
  13.  
  14. void solve() {
  15. int a, b, c;
  16. // Input three positive integers a, b, c (1 <= a, b, c <= 50)
  17. // f(B, C) = a
  18. // f(C, A) = b
  19. // f(A, B) = c
  20. if (!(cin >> a >> b >> c)) return;
  21.  
  22. // K is the size of the separator block of zeros.
  23. // Since max(a, b, c) is 50, a block of 50 zeros is sufficient to
  24. // prevent any interleaving match of '1's between sections.
  25. const int K = 50;
  26. string Z = generate_string('0', K);
  27.  
  28. // --- Define the three main sections (Blocks) ---
  29. // The three sections are S_c, S_a, S_b.
  30. // S_c (size c): Controls LCS(A, B) = c
  31. string S_c_1 = generate_string('1', c);
  32. string S_c_0 = generate_string('0', c);
  33.  
  34. // S_a (size a): Controls LCS(B, C) = a
  35. string S_a_1 = generate_string('1', a);
  36. string S_a_0 = generate_string('0', a);
  37.  
  38. // S_b (size b): Controls LCS(C, A) = b
  39. string S_b_1 = generate_string('1', b);
  40. string S_b_0 = generate_string('0', b);
  41.  
  42. // --- Construct Strings A, B, C ---
  43. // Each string has the structure: (Block c) + Z + (Block a) + Z + (Block b) + Z
  44. // A and B share '1's in S_c.
  45. // B and C share '1's in S_a.
  46. // C and A share '1's in S_b.
  47.  
  48. // String A: (1^c) + Z + (0^a) + Z + (1^b) + Z
  49. string A = S_c_1 + Z +
  50. S_a_0 + Z +
  51. S_b_1 + Z;
  52.  
  53. // String B: (1^c) + Z + (1^a) + Z + (0^b) + Z
  54. string B = S_c_1 + Z +
  55. S_a_1 + Z +
  56. S_b_0 + Z;
  57.  
  58. // String C: (0^c) + Z + (1^a) + Z + (1^b) + Z
  59. string C = S_c_0 + Z +
  60. S_a_1 + Z +
  61. S_b_1 + Z;
  62.  
  63. // Output the resulting binary strings, separated by newlines or spaces (based on the problem description)
  64. // The problem asks for "In ra ba xâu nhị phân A, B, C trên ba dòng." (Output the three binary strings A, B, C on three lines.)
  65. cout << A << endl;
  66. cout << B << endl;
  67. cout << C << endl;
  68. }
  69.  
  70. int main() {
  71. // Fast I/O
  72. ios_base::sync_with_stdio(false);
  73. cin.tie(NULL);
  74.  
  75. solve();
  76.  
  77. return 0;
  78. }
Success #stdin #stdout 0.01s 5320KB
stdin
4 2 3
stdout
111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000
111000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000001111000000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000