Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <cstring>
- #include <string>
- #include <string.h>
- #include <math.h>
- #include <stdio.h>
- #include <ctime>
- #include <cmath>
- #include <algorithm>
- #include <tuple>
- #include <functional>
- #include <utility>
- #include <cstdio>
- #include <deque>
- #include <vector>
- using namespace std;
- vector <int> roads[2001];
- string operator*(string s, size_t count)
- {
- string ret="";
- for(size_t i = 0; i < count; ++i)
- {
- ret = ret + s;
- }
- return ret;
- }
- int main()
- {
- int M,longestlen,repeats;
- scanf("%d",&M);
- string s;
- double ans;
- for (int i=0;i<M;i++)
- {
- int len=0;
- scanf("%d %s",&len,&s);
- printf("%s\n",s.substr(0,2));
- printf("%s %s\n",s.substr(0,2) ,s.substr(s.length()-2+1 ,s.length()-2) );
- for (int j=2;j<=(int)ceil((double)M/2)+1;j++)
- {
- string x=s.substr(0,j);
- string y=s.substr(s.length()-j+1,s.length()-j);
- if ( x==y && M%j==0)
- {
- len=j;
- }
- }
- if (len>longestlen)
- {
- longestlen=len;
- repeats=M/longestlen;
- }
- }
- printf("%d%d\n",longestlen,repeats);
- ans=longestlen/(double)repeats;
- printf("%f",ans);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement