A. Escalator Conversations
Problem
[题目](Rudolph and Cut the Rope)
Sol & Code
绳子长度大于钉子高度的要剪
#include <bits/stdc++.h>
typedef long long ll;
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int T, n;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
int a, b, ans = 0;
for (int i = 1; i <= n; ++i) {
scanf("%d %d", &a, &b);
if (a > b) ++ans;
}
printf("%d\n", ans);
}
return 0;
}
B. Rudolph and Tic-Tac-Toe
Problem
Sol & Code
签到。
#include <bits/stdc++.h>
typedef long long ll;
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int T;
std::string s[4];
bool solve(char c) {
for (int i = 1; i <= 3; ++i) {
for (int j = 0; j < 3; ++j) {
if (s[i][j] != c) break;
if (j == 2) return true;
}
}
for (int j = 0; j < 3; ++j) {
for (int i = 1; i <= 3; ++i) {
if (s[i][j] != c) break;
if (i == 3) return true;
}
}
if (s[1][0] == s[2][1] && s[1][0] == s[3][2] && s[1][0] == c) return true;
if (s[1][2] == s[2][1] && s[1][2] == s[3][0] && s[1][2] == c) return true;
return false;
}
int main() {
scanf("%d", &T);
while (T--) {
std::cin>>s[1];
std::cin>>s[2];
std::cin>>s[3];
if (solve('O')) puts("O");
else if (solve('X')) puts("X");
else if (solve('+')) puts("+");
else puts("DRAW");
}
return 0;
}
C. Rudolf and the Another Competition
Problem
Sol & Code
签到
但是我爆 \(int\) 了
#include <bits/stdc++.h>
#define N 200001
typedef long long ll;
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int T, n, m, h, a[N];
struct qwq {
int p, id;
ll c;
friend bool operator < (qwq q1, qwq q2) {
if (q1.p == q2.p) {
if (q1.c == q2.c) return q1.id < q2.id;
return q1.c < q2.c;
}
return q1.p > q2.p;
}
}rk[N];
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d %d %d", &n, &m, &h);
for (int i = 1; i <= n; ++i) {
rk[i].id = i, rk[i].p = 0, rk[i].c = 0;
for (int j = 1; j <= m; ++j) scanf("%d", &a[j]);
std::sort(a + 1, a + m + 1);
for (int j = 1; j <= m; ++j) {
a[j] += a[j - 1];
if (a[j] <= h) ++rk[i].p, rk[i].c += a[j];
else break;
}
}
std::sort(rk + 1, rk + n + 1);
for (int i = 1; i <= n; ++i) {
if (rk[i].id == 1) { printf("%d\n", i); break; }
}
}
return 0;
}
D. Rudolph and Christmas Tree
Problem
Sol & Code
从上向下算面积处理重复即可。
#include <bits/stdc++.h>
#define N 200001
typedef long long ll;
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int T, n, d, h, a[N];
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d %d %d", &n, &d, &h);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
int last = 2147483647;
double ans = 0;
for (int i = n; i >= 1; --i) {
if (a[i] + h > last) {
double bili = 1.0 * (a[i] + h - last) / h;
ans += (1.0 - bili * bili) * d * h / 2.0;
} else ans += 1.0 * d * h / 2.0;
last = a[i];
}
printf("%0.7lf\n", ans);
}
return 0;
}
E1. Rudolf and Snowflakes (simple version)
Problem
Sol & Code
雪花是一颗深度大于 \(2\) 的满 \(k\) 叉树,因节点总数 \(n\) 很小,可以暴力判断。
#include <bits/stdc++.h>
typedef long long ll;
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
ll n;
int T;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%lld", &n);
bool okay = false;
for (ll i = 2; i < n; ++i) {
if (i * i + i + 1 > n) break;
if (i * i + i + 1 == n) { okay = true; break; }
if (n - 1)
}
puts(okay ? "YES" : "NO");
}
return 0;
}
标签:883,q1,return,int,题解,ll,long,Div,scanf
From: https://www.cnblogs.com/poi-bolg-poi/p/17743821.html