fork download
  1. // i wants to take ioi
  2. //binhtinhtutinkhongcaycunhungmotkhikhongcontutinnualatuyetvong
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. #define int long long
  8. #define nn "\n"
  9. #define pi pair<int, int>
  10. #define fi first
  11. #define se second
  12. #define lb lower_bound
  13. #define ub upper_bound
  14. #define eb emplace_back
  15. #define pb push_back
  16. #define TASK " "
  17.  
  18. #define ms(a, x) memset(a, x, sizeof(a))
  19. #define all(a) a.begin(), a.end()
  20. #define All(a, n) a + 1, a + 1 + n
  21.  
  22. #define LOG 19
  23.  
  24.  
  25. const int INF = 1e18;
  26. const int mod = 1e9+7;
  27. const int N = 1e5 + 5;
  28. int MOD = 998244353;
  29. int bit[200000];
  30. struct node{
  31. int kc, u, hk;
  32. bool operator<(const node& other) const {
  33. return kc > other.kc;
  34. }
  35. };
  36. struct edge{
  37. int v, w, h;
  38. };
  39.  
  40. void nhap(){
  41.  
  42. }
  43. void solve(){
  44. string s; cin >> s;
  45. int n = s.size();
  46. for(int len = 1; len <= n; len++){
  47. if(n % len == 0){
  48. string x = s.substr(0, len);
  49. string temp = "";
  50. int t = n / len;
  51. for(int i = 0; i < t; i++){
  52. temp += x;
  53. }
  54. if(temp == s){
  55. cout << x << nn;
  56. return;
  57. }
  58. }
  59. }
  60. }
  61. signed main() {
  62. // freopen("npms.inp", "r", stdin);
  63. // freopen("npms.out", "w", stdout);
  64. ios_base::sync_with_stdio(0);
  65. cin.tie(0);
  66. cout.tie(0);
  67. nhap();
  68. solve();
  69. return 0;
  70.  
  71. }
  72.  
Success #stdin #stdout 0.01s 5284KB
stdin
abababab
stdout
ab