Codeforces Round #644 (Div. 3) 题解
作者:互联网
题目链接:https://codeforces.com/contest/1360
/* A题 creat by dzz */ #include <bits/stdc++.h> using namespace std; int main () { int T; cin >> T; while(T--) { int a, b; cin >> a >> b; if(a > b) { swap(a, b); } // int c = 2 * a * b; if(a * a >= 2 * a * b || b * b >= 2 * a * b) { cout << (a * a >= 2 * a * b ? a * a : b * b) << endl; continue; } cout << (4 * a * a >= 2 * a * b ? 4 * a * a : 4 * b * b) << endl; } }
/* B题 creat by dzz */ #include <bits/stdc++.h> using namespace std; int main () { int T; cin >> T; while(T--) { int n; cin >> n; std::vector<int> v; while(n--) { int temp; cin >> temp; v.push_back(temp); } sort(v.begin(), v.end()); int ans = 0x3f3f3f3f; for(int i = 1; i < v.size(); ++i) { ans = min(ans, v[i] - v[i - 1]); } cout << ans << endl; } }
/* C题 creat by dzz */ #include <bits/stdc++.h> using namespace std; int main () { int T; cin >> T; while(T--) { int n; cin >> n; std::vector<int> v; int oddnum = 0; for(int i = 0; i < n; ++i){ int temp; cin >> temp; if(temp & 1) { oddnum++; } v.push_back(temp); } int oddeven = n - oddnum; if(!(oddnum & 1)) { cout << "YES" << endl; } else { bool ok = 0; sort(v.begin(), v.end()); for(int i = 1; i < v.size(); ++i) { if(v[i] - v[i - 1] == 1) { ok = 1; break; } } if(ok) { cout << "YES" << endl; } else { cout << "NO" << endl; } } } }
/* D题 creat by dzz */ #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n, p; int t; cin >> t; while(t--){ cin >> n >> p; int ans = 0; for(int i = 1; i * i <= n && i <= p; i++) { if(n % i == 0){ ans = max(ans, i); if(n / i <= p) ans = max(ans, n / i); } } ans = n / ans; cout << ans<< endl; } return 0; }
/* E题 creat by dzz */ #include <bits/stdc++.h> using namespace std; typedef long long ll; char a[100][100]; int main() { ll t; cin >> t; ll n; while(t--){ int n; cin >> n; for(int i = 0; i < n; ++i) { cin >> a[i]; } bool flag = 1; for(int i = 0; i < n - 1; ++i) { for(int j = 0; j < n - 1; ++j) { if(a[i][j] == '1' && a[i + 1][j] == '0' && a[i][j + 1] == '0') { flag = 0; break; } if(!flag) { break; } } } if(flag) { cout << "YES" << endl; } else { cout << "NO" << endl; } } return 0; }
/* F题 creat by dzz */ #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); ll t; cin >> t; while(t--){ string s[15]; int n, m; cin >> n >> m; for(int i = 0; i < n; ++i) { cin >> s[i]; } string ans = "-1"; function<bool(string)> check = [&](string t) { for(int i = 0; i < n; ++i) { int cnt = 0; for(int j = 0; j < m; ++j) { cnt += (s[i][j] != t[j]); //不等cnt++ } if(cnt > 1) { return false; } } return true; }; for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) { for(int k = 0; k < 26; ++k) { string ss = s[i]; ss[j] = 'a' + k; if(check(ss)) { ans = ss; } } } } cout << ans << endl; } return 0; }
标签:std,temp,int,题解,cin,++,while,644,Div 来源: https://www.cnblogs.com/lightac/p/12955074.html