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为还需要的蜡烛数, ...
随机推荐
- shell命令-lsof
前言 lsof是系统管理常用命令,其名指的是list open files,列出打开的文件,而在linux系统,一切皆文件. centos7安装:yum install -y lsof 获取网络信息 ...
- 2.0 Python 数据结构与类型
数据类型是编程语言中的一个重要概念,它定义了数据的类型和提供了特定的操作和方法.在 python 中,数据类型的作用是将不同类型的数据进行分类和定义,例如数字.字符串.列表.元组.集合.字典等.这些数 ...
- VMware中的虚拟机Debian10的服务器配置,使主机(win10)能够通过本地域名(如www.xxx.com)访问该服务器
VMware中的虚拟机Debian10的服务器配置,使主机(win10)能够通过本地域名(如www.xxx.com)访问该服务器 安装过程 下载debian-10.13.0-amd64-DVD-1.i ...
- Linux cpu 亲缘性 绑核
前言 https://www.cnblogs.com/studywithallofyou/p/17435497.html https://www.cnblogs.com/studywithallofy ...
- [PWN之路]堆攻击那些事儿
原文:https://www.freebuf.com/articles/endpoint/371095.html 0x00 前言 根据某大佬所说,pwn之路分为栈,堆,和内核.当前,如果你看到这个文章 ...
- 探索API接口:从概念到实践
在当今数字化时代,API(Application Programming Interface)接口成为了各种应用程序之间实现数据交互和功能集成的关键.无论是开发一个网站.构建一个移动应用还是进行数据分 ...
- Go开始:Go基本元素介绍
本文深入探讨了Go编程语言中的核心概念,包括标识符.关键字.具名函数.具名值.定义类型.类型别名.包和模块管理,以及代码块和断行.这些元素是构成Go程序的基础,也是编写高质量代码的关键. 关注Tech ...
- Note -「SOS DP」高维前缀和
本文差不多算是翻译了一遍 CF blog?id=45223 就是抄了一遍,看不懂可以去原文. 当然我的翻译并不是完全遵从原文的. Part. 1 Introduction 平时我们怎么求高维前缀和?容 ...
- SonarQube系列-认证&授权的配置
参考文档:https://docs.sonarqube.org/latest/instance-administration/security/ 概述 SonarQube具有许多全局安全功能: 认证和 ...
- c语言代码练习12
//计算1/1-1/2+1/3...-1/100的和#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() { in ...