fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct mod {
  5. mod(): v(0) {}
  6. mod &operator<<(int v2) {
  7. v = v ? v % v2 : v2;
  8. return *this;
  9. }
  10. operator int() {
  11. return v;
  12. }
  13. int v;
  14. } mod;
  15.  
  16. template<int a>
  17. bool mozliwe() {
  18. return a;
  19. }
  20.  
  21. bool prawda() {
  22. return mozliwe<1>();
  23. }
  24.  
  25. bool falsz() {
  26. return mozliwe<0>();
  27. }
  28.  
  29. struct napis_t {
  30. napis_t(const std::string &value): v(value) {}
  31. char operator[](int idx) { return v[idx - 1]; }
  32. string v;
  33. };
  34.  
  35. void wypisz(const std::string &value) {
  36. cout << value;
  37. }
  38.  
  39. void wypisz(char value) {
  40. cout << value;
  41. }
  42.  
  43. int main() {
  44. string wartosc;
  45. int n;
  46. bool mozliwe = falsz();
  47. cin >> n;
  48. cin >> wartosc;
  49. napis_t napis(wartosc);
  50.  
  51. if ((mod << n << 2) == 0) {
  52. mozliwe = prawda();
  53. for(int i=1; i <= n / 2; i++) {
  54. if(napis[i] != napis[i + n / 2]) {
  55. mozliwe = falsz();
  56. }
  57. }
  58. }
  59.  
  60. if (mozliwe) {
  61. wypisz("(");
  62. for(int i=1; i <= n / 2; i++) {
  63. wypisz(napis[i]);
  64. }
  65. wypisz(")");
  66. }
  67. return 0;
  68. }
Success #stdin #stdout 0s 4404KB
stdin
2
22
stdout
(2)