6 条题解
-
1
这是一种不一样的做法
#include <iostream> #include <string.h> #include <cstdio> #include <algorithm> #include <string> #include <iomanip> #include <math.h> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; using namespace std; string a, b; int ans1, ans2; int main() { cin >> a >> b; for(int i = 0; i < a.size(); i++) { if(a[i] == b[0]) { int tmp = 0; for(int k = 0; k < b.size(); k++) { int j = i + k; if(a[j] == b[k])tmp++; else break; } ans1 = max(ans1, tmp); } } for(int i = 0; i < b.size(); i++) { if(b[i] == a[0]) { int tmp = 0; for(int j = 0; j < a.size(); j++) { int k = i + j; if(a[j] == b[k])tmp++; else break; } ans2 = max(ans2, tmp); } } if(max(ans1, ans2) == 6)cout << 1; else cout << max(ans1, ans2); return 0; }
信息
- ID
- 1120
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 9
- 标签
- 递交数
- 243
- 已通过
- 24
- 上传者