Codeforces Hongcow Learns the Cyclic Shift
/*
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
const int mod = 1000007;
const int high = 100;
int main()
{
fast;
string s , tmp , parmanent;
int len , i , j , cnt=0;
while(cin >> s)
{
cnt=1;
parmanent = s;
len = s.length();
i = len-1;
tmp = s[i];
for(j=0; j<i; j++)
{
tmp+=s[j];
}
while(tmp != parmanent)
{
cnt+=1;
s = tmp;
len = s.length();
i = len-1;
tmp = s[i];
for(j=0; j<i; j++)
{
tmp+=s[j];
}
}
cout << cnt << "\n";
}
return 0;
}
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
const int mod = 1000007;
const int high = 100;
int main()
{
fast;
string s , tmp , parmanent;
int len , i , j , cnt=0;
while(cin >> s)
{
cnt=1;
parmanent = s;
len = s.length();
i = len-1;
tmp = s[i];
for(j=0; j<i; j++)
{
tmp+=s[j];
}
while(tmp != parmanent)
{
cnt+=1;
s = tmp;
len = s.length();
i = len-1;
tmp = s[i];
for(j=0; j<i; j++)
{
tmp+=s[j];
}
}
cout << cnt << "\n";
}
return 0;
}
Comments
Post a Comment