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为还需要的蜡烛数, ...
随机推荐
- 【必看!】阿里云推出QWen-7B和QWen-7b-Chat,开放免费商用!
阿里云于8月3日宣布开源两款重要的大型模型--QWen-7B和QWen-7b-Chat.这两款模型的参数规模达到了令人瞩目的70亿,并且已经在Hugging Face和ModelScope平台上开放, ...
- [redis]定制封装redis的docker镜像
前言 应开发需求,定制封装redis的docker镜像,需要通过环境变量修改redis的密码. redis.conf port 6379 requirepass REDIS_PASSWD daemon ...
- 浅谈 Linux 下 vim 的使用
Vim 是从 vi 发展出来的一个文本编辑器,其代码补全.编译及错误跳转等方便编程的功能特别丰富,在程序员中被广泛使用. Vi 是老式的字处理器,功能虽然已经很齐全了,但还有可以进步的地方.Vim 可 ...
- 论文解读(TAMEPT)《A Two-Stage Framework with Self-Supervised Distillation For Cross-Domain Text Classification》
论文信息 论文标题:A Two-Stage Framework with Self-Supervised Distillation For Cross-Domain Text Classificati ...
- 《Kali渗透基础》02. 基本工具
@ 目录 1:基本工具 1.1:NetCat 1.1.1:命令参数 1.1.2:示例 1.2:NCat 1.2.1:命令参数 1.2.2:示例 1.3:WireShark 1.4:TCPdump 1. ...
- 《Python魔法大冒险》006 变量的迷雾
小鱼和魔法师走了很久,终于来到了一个神秘的森林前.这片森林与众不同,它被一层厚厚的迷雾所包围,仿佛隐藏着无尽的秘密. 小鱼好奇地看着这片森林:"这是什么地方?" 魔法师:这是魔法森 ...
- Abp vNext 模块加载机制
文章目录 生命周期 PreConfigureServices 添加依赖注入或者其它配置之前 ConfigureServices 添加依赖注入或者其它配置 PostConfigureServices 添 ...
- c语言代码练习11
//1-100数字中9的数量 #define _CRT_SECURE_NO_WARNINGS 1#include <stdio.h> int main(){ int x = 0; int ...
- c语言代码练习3
//查看数字是否存在于数组中#define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() { int i = 0; int ...
- MySQL系列之MHA高可用——主从复制架构演变介绍、高可用MHA、管理员在高可用架构维护的职责
文章目录 1. 主从复制架构演变介绍 1.1 基本结构 1.2 高级应用架构演变 1.2.1 高性能架构 1.2.2 高可用架构 2. 高可用MHA ***** 2.1 架构工作原理 2.2 架构介绍 ...