A. Vlad and the Best of Five
思路:
给你一个长度字符串只包含A和B输出最多的字符
解法:
按题意来
Code:
#include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t --) { string s; cin >> s; int cnt = 0; for (char x : s) { if (x == 'A') { cnt++; } } if (cnt > 2) { cout << 'A' << '\n'; } else { cout << 'B' << '\n'; } } return 0; }
Code:
#include<bits/stdc++.h> using namespace std; void solve() { int n; cin >> n; vector<string> s(n + 1); for (int i = 1; i <= n; i++) { cin >> s[i]; s[i] = '#' + s[i]; } int miy = 15, may = -1, cnt = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (s[i][j] == '1') { miy = min(miy, j); may = max(may, j); cnt++; } } } cout << ((may - miy + 1) * (may - miy + 1) == cnt ? "SQUARE\n" : "TRIANGLE\n"); } int main() { int t; cin >> t; while (t--) { solve(); } return 0; } /* TRIANGLE SQUARE */
标签:cnt,int,namespace,cin,Codeforces,928,include,Round From: https://www.cnblogs.com/youhualiuh/p/18023006