# 2021暑假模拟赛9

A[HDU7053(800)]

#include<cstdio>
const double eps = 1e-4;
int T;
double p,q;
void sol()
{
scanf("%lf%lf",&p,&q);
if(q>=p)puts("N0 M0R3 BL4CK 1CE TEA!");
else puts("ENJ0Y YOURS3LF!");
}
int main()
{
scanf("%d",&T);
while(T--)sol();
return 0;
}
View Code

B[GYM103102B(1600)]

#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string S;
cin >> S;
int N = S.size();
long long cnt = 0;
long long zero = 0;
for (int i = N - 1; i >= 0; --i) {
if (S[i] == '0') {
zero ++;
} else {
cnt += zero;
}
}
if (cnt % 3 == 0) {
cout << "Bob" << '\n';
} else {
cout << "Alice" << '\n';
}
}
View Code

C[HDU7055(1600)]

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 998244353;
int pre[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int n = s.size();
long long ans = 0;
for (char c = 'a'; c <= 'z'; ++c) {
for (int i = 0; i < n; ++i) {
pre[i + 1] = pre[i] + (s[i] == c);
}
long long s = 0;
for (int i = 1; i <= n; ++i) {
ans += 1ll * pre[i] * pre[i] * n;
ans -= 2ll * pre[i] * s;
ans %= mod;
if (ans < 0) {
ans += mod;
}
s += pre[i];
}
}
cout << ans << '\n';
}
}
View Code

D[CF1537F(2200)]

#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T --> 0) {
int N, M;
cin >> N >> M;
vector<long long> v(N);
for (int i = 0; i < N; ++i) {
cin >> v[i];
}
vector<long long> t(N);
for (int i = 0; i < N; ++i) {
cin >> t[i];
}
for (int i = 0; i < M; ++i) {
int X, Y;
cin >> X >> Y;
X --;
Y --;
}
vector<int> col(N, -1);
auto dfs = [&] (auto &&f, int X, int C) -> bool {
col[X] = C;
for (int Y : adj[X]) {
if (col[Y] == -1) {
if (!f(f, Y, C ^ 1)) {
return false;
}
} else if (col[X] == col[Y]) {
return false;
}
}
return true;
};
if (!dfs(dfs, 0, 0)) {
if (abs(accumulate(v.begin(), v.end(), 0LL)) % 2 == abs(accumulate(t.begin(), t.end(), 0LL)) % 2) {
cout << "YES" << '\n';
} else {
cout << "NO" << '\n';
}
} else {
vector<long long> dv(2);
vector<long long> dt(2);
for (int i = 0; i < N; ++i) {
dv[col[i]] += v[i];
dt[col[i]] += t[i];
}
if (dv[0] - dt[0] == dv[1] - dt[1]) {
cout << "YES" << '\n';
} else {
cout << "NO" << '\n';
}
}
}
}
View Code

posted @ 2021-08-11 10:00  19992147  阅读(45)  评论(0编辑  收藏  举报