SRM 690 div2 easy DoubleString
問題概要
文字列Sが与えられる。その文字列がS = T + T となる文字列Tが存在するか。
解法
Tが2回続くので、TはSの文字列の長さの1/2なので、Sを前後で二等分した文字列どおしが同じものであるかを見ればよい。
ミス
なし。
コード
#include <iostream> #include <string> #include <vector> #include <cstdio> #include <queue> #include <algorithm> using namespace std; typedef long long ll; #define rep(i,n) for(int i=0;i<(n);i++) class DoubleString{ public: string check(string S){ string t1, t2; t1 = S.substr(0, S.size() / 2); cout << t1 << endl; t2 = S.substr(S.size()/ 2); cout << t2 << endl; if(t1 == t2)return "square"; else return "not square"; } };