Advertisement
Ilikebugs

C++ libraries

Dec 24th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <cstring>
  3. #include <string>
  4. #include <string.h>
  5. #include <math.h>
  6. #include <stdio.h>
  7. #include <ctime>
  8. #include <cmath>
  9. #include <algorithm>
  10. #include <tuple>
  11. #include <functional>
  12. #include <utility>
  13. #include <cstdio>
  14. #include <deque>
  15. #include <vector>
  16. using namespace std;
  17. vector <int> roads[2001];
  18.  
  19. string operator*(string s, size_t count)
  20. {
  21.     string ret="";
  22.     for(size_t i = 0; i < count; ++i)
  23.     {
  24.         ret = ret + s;
  25.     }
  26.     return ret;
  27. }
  28.  
  29. int main()
  30. {
  31.     int M,longestlen,repeats;
  32.     scanf("%d",&M);
  33.     string s;
  34.     double ans;
  35.     for (int i=0;i<M;i++)
  36.     {
  37.         int len=0;
  38.         scanf("%d %s",&len,&s);
  39.         printf("%s\n",s.substr(0,2));
  40.         printf("%s %s\n",s.substr(0,2) ,s.substr(s.length()-2+1  ,s.length()-2) );
  41.         for (int j=2;j<=(int)ceil((double)M/2)+1;j++)
  42.         {
  43.             string x=s.substr(0,j);
  44.             string y=s.substr(s.length()-j+1,s.length()-j);
  45.             if ( x==y  && M%j==0)
  46.             {
  47.                 len=j;
  48.             }
  49.         }
  50.         if (len>longestlen)
  51.         {
  52.             longestlen=len;
  53.             repeats=M/longestlen;
  54.         }
  55.     }
  56.     printf("%d%d\n",longestlen,repeats);
  57.     ans=longestlen/(double)repeats;
  58.     printf("%f",ans);
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement