Codeforces Round 883 (Div. 3)
Codeforces Round 883 (Div. 3)
A. Rudolph and Cut the Rope
题意:有一颗糖果在连在绳子上,求剪短多少根绳子,他能落地
思路:只要绳子长度比钉子高度大就不用减
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, res = 0;
cin >> n;
while (n--) {
int a, b;
cin >> a >> b;
if (a > b) {
res++;
}
}
cout << res << "\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
B. Rudolph and Tic-Tac-Toe
题意:井字棋判断谁赢谁输
思路:8种情况,判断就行
#include <bits/stdc++.h>
using namespace std;
char mp[4][4];
void solve() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
cin >> mp[i][j];
}
}
for (int i = 0; i < 3; i++) {
bool x = true, y = true;
for (int j = 1; j < 3; j++) {
if (x && mp[i][j] != mp[i][j - 1]) {
x = false;
}
if (y && mp[j][i] != mp[j - 1][i]) {
y = false;
}
if (!x && !y) break;
}
if (x && mp[i][0] != '.') {
cout << mp[i][0] << "\n";
return;
}
if (y && mp[0][i] != '.') {
cout << mp[0][i] << "\n";
return;
}
}
bool w = true;
for (int i = 1; i < 3; i++) {
if (mp[i][i] != mp[i - 1][i - 1]) {
w = false;
break;
}
}
if (w && mp[1][1] != '.') {
cout << mp[1][1] << "\n";
return;
}
w = true;
for (int i = 1; i < 3; i++) {
if (mp[i][2 - i] != mp[i - 1][3 - i]) {
w = false;
break;
}
}
if (w && mp[1][1] != '.') {
cout << mp[1][1] << "\n";
return;
}
cout << "DRAW\n";
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
C. Rudolf and the Another Competition
题意:判断这个人在第几名
思路:优先级:题目数>罚时(重写cmp)老顽固真不喜欢运算符重载
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct Stu {
int num;//题数
int time;//罚时
int c;//那个b
};
bool cmp(Stu c, Stu b) {
if (c.num != b.num) {
return c.num > b.num;
}
if (c.time != b.time) {
return c.time < b.time;
}
return c.c > b.c;
}
void solve() {
int n, m, h;
cin >> n >> m >> h;
vector<Stu> a(n + 1);
for (int i = 1; i <= n; i++) {
vector<int> b(m + 1);
for (int j = 1; j <= m; j++) cin >> b[j];
sort(b.begin() + 1, b.end());
int cnt = 0, sum = 0, cur = 0;
for (int j = 1; j <= m; j++) {
if (cur + b[j] <= h) {
cnt++;
cur += b[j];
sum += cur;
}
}
a[i] = {cnt, sum, 0};
if (i == 1) a[i].c = 1;
}
sort(a.begin() + 1, a.end(), cmp);
for (int i = 1; i <= n; i++) {
if (a[i].c == 1) {
cout << i << endl;
return;
}
}
}
signed main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
D. Rudolph and Christmas Tree
题意:有n个等腰三角形,有重叠,求他们的面积
思路:总面积-重叠的面积
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 10;
int a[MAX];
void solve() {
int n;
double h, d;
cin >> n >> d >> h;
double s = h * n * d / 2;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
double res = 0;
for (int i = 0; i < n - 1; i++) {
if (a[i] + h > a[i + 1]) {
res += (double) (a[i] + h - a[i + 1]) * (a[i] + h - a[i + 1]) * d / (2 * h);
}
}
printf("%.6lf\n", s - res);
}
int main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
E1. Rudolf and Snowflakes (simple version)
题意:求n=k1+k2+..+k^x
思路:简单版直接爆爆爆爆力
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve()
{
int n;
cin>>n;
for(int i=2;i<=n;i++){
int sum = 1+i+i*i ;
int temp = i*i ;
if (sum > n) break;
while (sum < n)
{
temp *= i;
sum += temp;
}
if (sum == n)
{
cout << "YES\n" ;
return;
}
}
cout<<"NO\n";
}
signed main()
{
int t;
cin>>t;
while(t--){
solve();
}
return 0;
}
E2. Rudolf and Snowflakes (hard version)
他甚至爆unsigned long long 只能开int_128(shu)
题意:求n=k1+k2+..+k^x(变的是n的范围,所以暴力直接达咩)
$$
很明显等比数列求和:n=a_1*(1-k^x)/(1-q);
$$
思路:n<2e18最大也就2^64,x遍历[2,64],k遍历[2,1e9] (二分遍历)
二分板子:
while (l < r)
{
int mid = l + r >> 1;
if (check(mid)) r = mid; // check()判断mid是否满足性质
else l = mid + 1;
}
return l;
#include <bits/stdc++.h>
using namespace std;
#define int long long
int check(int k, int x) {//k底数x指数
__int128 cur = 1, res = 1;
for (int i = 1; i <= x; i++) {
cur *= k;
res += cur;
if (res >= 2e18) return 2e18;
}
return (int) (res);
}
void solve() {
int n;
cin >> n;
for (int x = 2; x <= 63; x++) {
int l = 2, r = 1e9;
while (l < r) {
int mid = (l + r) >> 1;
int t = check(mid, x);
if (t >= n)
r = mid;
else
l = mid + 1;
}
if (check(l, x) == n) {
cout << "YES\n";
return;
}
}
cout << "NO\n";
}
signed main() {
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Codeforces Round 883 (Div. 3)的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
随机推荐
- Stable Diffusion基础:ControlNet之图片风格迁移
今天继续给大家分享AI绘画中 ControlNet 的强大功能,本次的主角是 Reference,它可以将参照图片的风格迁移到新生成的图片中,这句话理解起来很困难,我们将通过几个实例来加深体会,比如照 ...
- SpringBoot3集成RocketMq
标签:RocketMq5.Dashboard: 一.简介 RocketMQ因其架构简单.业务功能丰富.具备极强可扩展性等特点被广泛应用,比如金融业务.互联网.大数据.物联网等领域的业务场景: 二.环境 ...
- 《SQL与数据库基础》20. 主从复制
目录 主从复制 原理 搭建 主库配置 从库配置 测试 本文以 MySQL 为例 主从复制 主从复制是指将主数据库的 DDL 和 DML 操作通过二进制日志传到从库服务器中,然后在从库上对这些日志重新执 ...
- GaoNeng:我是如何为OpenTiny贡献新组件的?
本文共10076字,预计阅读20分钟 大家好啊,又是我GaoNeng.最近在给OpenTiny做贡献,感觉renderless这个架构还是挺有意思的,就贡献了一个color-picker组件,简单写篇 ...
- CCF 202012-5星际旅行(20~100分)
前置知识 线段树:通过懒惰标记,可实现区间处理,和区间询问皆为\(O(logn)\)时间复杂度的数据结构,是一种二叉树.因此对于一个节点\(st\),其左儿子节点为\(st*2\),右节点为\(st* ...
- K8s 多集群实践思考和探索
作者:vivo 互联网容器团队 - Zhang Rong 本文主要讲述了一些对于K8s多集群管理的思考,包括为什么需要多集群.多集群的优势以及现有的一些基于Kubernetes衍生出的多集群管理架构实 ...
- signalr断开连接后重新连接
signalr断开连接后重新连接 产品需求连接signalr 不稳定,连着连着就断了,场面十分尴尬,导致产品经理现场被批!!(内心无比高兴 ) 分析得出问题现象: 服务器因某些特殊原因,导致服务停止一 ...
- 开源通用型流式大数据统计系统XL-LightHouse介绍
概述 XL-LightHouse是针对互联网领域繁杂的流式数据统计需求而开发的一套集成了数据写入.数据运算.数据存储和数据可视化等一系列功能,支持大数据量,支持高并发的[通用型流式大数据统计平台]: ...
- 慢SQL原因分析之索引失效
现象 最近收到一个慢sql工单,慢sql大概是这样:"select xxx from tabel where type = 1". 咦,type字段明明有索引啊,为啥是慢sql呢? ...
- 【Flutter】如何优美地实现一个悬浮NavigationBar
[Flutter]如何优美地实现一个悬浮NavigationBar 最近写代码的时候遇到了一个如下的需求: 整体来说,底部的条是一个浮动的悬浮窗,有如下的三个按钮: 点击左边的要进入"主页& ...