1163: Affinity String (String) time limit: 1 Sec Memory Limit: MB
Submit: 983 Solved: 392
Submitstatusweb Board Description
Determine affinity strings. The definition of affinity string is this: given two strings S1 and S2, if the S2 can be included in S1 by S1 cycle, then we say S2 is the affinity string of S1.
InputThere are several sets of test data, the first row of each group of data contains the input string s1, the second line contains the input string s2,s1 and s2 length are less than 100000.
OutputasFruit S2 is the affinity string of S1, then output "yes", conversely, output "no". The output for each group of tests is one row.
Sample InputAABCDCdaaASDASDFABABASample OutputYesNoNoidea: Reference source http://www.docin.com/p-558891657.html If the string length of a is less than B, it is sure that a does not change to B. If a string length is greater than or equal to B string length, then a copy into two copies into a, and then from a string to find there are no strings like B string.
#include <iostream> #include <string>using namespace Std;int main () { string a B; int position; while (cin>>a>>b) { if (a.size () <b.size ()) { cout<< "no" <<endl; } else { a=a+a; Position=a.find (b); if (position==-1) cout<< "No" <<endl; else cout<< "yes" <<endl; } } return 0;}
Affinity String (String)