c += 'A' - 'a'
をすれば OK。#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
for (int i = 0; i < s.length(); ++i) s[i] += 'A' - 'a';
cout << s;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, q, t, x;
cin >> n >> q;
vector<int> yellow(n);
for (int i = 0; i < q; ++i) {
cin >> t >> x;
if (t == 3) cout << (yellow[x - 1] >= 2 ? "Yes" : "No") << '\n';
else yellow[x - 1] += t; // イエローカードなら t == 1、レッドカードなら t == 2 なので、
// t を足すとちょうどいい
}
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<ll> sum(n + 1);
for (int i = 1; i <= n; ++i) {
for (int j = i; j <= n; j += i) {
++sum[j];
}
}
ll ans = 0;
for (int i = 1; i < n; ++i) ans += sum[i] * sum[n - i];
cout << ans;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
// Union-Find
class UnionFind {
vector<int> p;
public:
UnionFind(int n) : p(n, -1) {}
void unite(int x, int y) {
x = find(x); y = find(y);
if (x == y) return;
if (p[x] < p[y]) {
p[x] += p[y];
p[y] = x;
} else {
p[y] += p[x];
p[x] = y;
}
return;
}
int find(int x) {
if (p[x] < 0) return x;
while (p[p[x]] >= 0) {
p[x] = p[p[x]];
x = p[x];
if (p[x] < 0) return x;
}
return p[x];
}
bool isSame(int x, int y) { return find(x) == find(y); }
int size(int x) { return -p[find(x)]; }
};
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> g(n);
UnionFind uni(n);
for (int i = 0, u, v; i < m; ++i) {
cin >> u >> v;
--u; --v;
g[u].push_back(v); g[v].push_back(u);
uni.unite(u, v);
}
vector<int> p(n); // p[i] は i を含む連結成分の代表
vector<int> size(n); // 代表が i である連結成分の頂点の個数
vector<int> e(n); // 代表が i である連結成分の各頂点の次数の総和
for (int i = 0; i < n; ++i) {
p[i] = uni.find(i);
size[p[i]] = uni.size(p[i]);
e[p[i]] += g[i].size();
}
bool ans = true;
for (int i = 0; i < n; ++i) {
if (size[i] * 2 != e[i]) {
ans = false;
break;
}
}
cout << (ans ? "Yes" : "No");
return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// 頂点 v から各頂点への距離を求める
vector<int> bfs(int v, vector<vector<int>> &g) {
queue<int> que;
vector<int> d(g.size(), -1);
que.push(v);
d[v] = 0;
while (!que.empty()) {
int v = que.front();
que.pop();
for (int child : g[v]) {
if (d[child] == -1) {
d[child] = d[v] + 1;
que.push(child);
}
}
}
return d;
}
int main() {
int n, m;
cin >> n >> m;
vector<vector<int>> g(n);
for (int i = 0, u, v; i < m; ++i) {
cin >> u >> v;
--u; --v;
g[u].push_back(v);
}
ll ans = 0;
for (int i = 0; i < n; ++i) {
auto d = bfs(i, g);
for (int j = 0; j < n; ++j) {
if (d[j] >= 2) ++ans;
}
}
cout << ans;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b;
const double PI = 3.141592653589793;
cin >> a >> b;
if (a > b) swap(a, b); // b を長辺とする
double ok = 0, ng = b;
for (double mid = (ok + ng) / 2; abs(ok - ng) > 1e-12; mid = (ok + ng) / 2) {
// 長方形の頂点の座標を (0, 0), (a, 0), (a, b), (0, b) として、
// 正三角形の頂点のうち、長方形の辺上の 2 点を (0, 0), (a, mid) としたときの
// 残りの 1 点 (c, d)
double c = a * cos(PI / 3) - mid * sin(PI / 3), d = mid * cos(PI / 3) + a * sin(PI / 3);
if (0 <= c && c <= a && 0 <= d && d <= b) ok = mid;
else ng = mid;
}
printf("%.16lf", sqrt(a * a + ok * ok));
return 0;
}
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
int main() {
int n, m;
const int b = 10;
cin >> n >> m;
vector<string> s(n);
for (int i = 0; i < n; ++i) cin >> s[i];
// dp[桁][l][r] ([l, r))
vector<vector<vector<mint>>> dp(m + 1, vector<vector<mint>>(n, vector<mint>(n + 1)));
for (int i = 0; i < n; ++i) dp[m][i][i + 1] = 1; // 最下位対応用
for (int i = m - 1; i >= 0; --i) {
// dp2[上から i 桁目の値が k 未満][l][r]
vector<vector<vector<mint>>> dp2(b + 1, vector<vector<mint>>(n, vector<mint>(n + 1)));
for (int l = 0; l < n; ++l) {
for (int k = 0; k <= b; ++k) dp2[k][l][l] = 1; // mid == l 対応用
for (int r = l + 1; r <= n; ++r) {
for (int k = 1; k <= b; ++k) {
dp2[k][l][r] = dp2[k - 1][l][r];
for (int mid = r - 1; mid >= l; --mid) {
if (s[mid][i] != k - 1 + '0' && s[mid][i] != '?') break;
// [mid, r) の 上から i 桁目の値がすべて k - 1 の場合を加算
dp2[k][l][r] += dp2[k - 1][l][mid] * dp[i + 1][mid][r];
}
}
dp[i][l][r] = dp2[b][l][r];
}
}
}
cout << dp[0][0][n].val();
return 0;
}
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using S = long long;
S op(S a, S b) { return max(a, b); }
S e() { return -(1e18); }
using F = long long;
S mapping(F f, S x) { return f + x; }
F composition(F f, F g) { return f + g; }
F id() { return 0; }
int main() {
int n, b, q;
cin >> n >> b >> q;
vector<S> a(n + 1);
for (int i = 1; i <= n; ++i) cin >> a[i], a[i] -= b; // B を引いて
for (int i = 1; i <= n; ++i) a[i] += a[i - 1]; // 累積和
lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
int c;
double x;
for (int i = 0; i < q; ++i) {
cin >> c >> x;
// 累積和なので seg.get(c) - seg.get(c - 1) == a_i - B
seg.apply(c, n + 1, (x - b) - (seg.get(c) - seg.get(c - 1)));
int r = min(n, seg.max_right(1, [](S x) { return x < 0; }));
printf("%.16lf\n", (double)seg.get(r) / r + b);
}
return 0;
}