51nod1347(简单逻辑)
生活随笔
收集整理的這篇文章主要介紹了
51nod1347(简单逻辑)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目鏈接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1347
?
題意:中文題誒~
?
思路:稍推理一下就可以發現字符串a是對偶串是其可以由對偶串旋轉得到的充要條件;
?
代碼:
1 #include <bits/stdc++.h> 2 using namespace std; 3 4 string b, a; 5 6 bool is_ok(string a){ 7 int len=a.size()/2; 8 for(int i=0; i<len; i++){ 9 if(a[i]!=a[i+len]){ 10 return false; 11 } 12 } 13 return true; 14 } 15 16 int main(void){ 17 cin >> a; 18 if(a.size()&1){ 19 cout << "NO" << endl; 20 return 0; 21 } 22 if(is_ok(a)){ 23 cout << "YES" << endl; 24 }else{ 25 cout << "NO" << endl; 26 } 27 return 0; 28 }?
轉載于:https://www.cnblogs.com/geloutingyu/p/6274860.html
總結
以上是生活随笔為你收集整理的51nod1347(简单逻辑)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 简易listview与adapter实现
- 下一篇: 极域电子教室创建和登录教师端的方法