Codeforces Round #774 (Div. 2)(A-C)

2023-05-16

Problem - A - Codeforces

签到题,判断s里面最多能够有多少个n^{2}

AC代码:

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include <iostream>
// #include <cstdio>
// #include <queue>
// #include <deque>
// #include <stack>
// #include <string>
// #include <cstring>
// #include <numeric>
// #include <functional>
// #include <cstdlib>
// #include <vector>
// #include <set>
// #include <map>
// #include <algorithm>
// #include <cmath>
// #include <iomanip>
using namespace std;
using i64 = long long;
#define lowbit(x) ((x) & -(x))
#define endl '\n'
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef long long ll;
// typedef long long i64;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T>
T power(T a, int b) {
	T res = 1;
	for (; b; b >>= 1, a = a * a) {
		if (b & 1) {
			res = res * a;
		}
	}
	return res;
}
template <typename T>
T Myabs(T a) {
	return a >= 0 ? a : -a;
}
template <typename T>
inline void read(T& x)
{
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - '0', ch = getchar(); }
	x *= f;
}
const int INF = 0x3f3f3f3f;
// const int mod = 1000000007;
const int mod = 998244353;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int sgn(double x) {
	return x < -eps ? -1 : x > eps;
}
/*
Tips:
   1.int? long long?
   2.don't submit wrong answer
   3.figure out logic first, then start writing please
   4.know about the range
   5.check if you have to input t or not
   6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/

void solve() {
	i64 n, s;
	cin >> n >> s;
	cout << s / (n * n) << endl;
	return;
}
signed main() {
	IOS1;
	// IOS2;
#ifdef ONLINE_JUDGE
#else
	freopen("in.txt", "r", stdin);
#endif
	int __t = 1;
	cin >> __t;
	for (int _t = 1; _t <= __t; _t++) {
		solve();
	}
	return 0;
}
/*
25820
*/

Problem - B - Codeforces

先进行排序,然后就是双指针问题,一前一后,判断有没有符合题意的,标红的和大于标蓝的和,标红的数量小于标蓝的数量

AC代码:

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include <iostream>
// #include <cstdio>
// #include <queue>
// #include <deque>
// #include <stack>
// #include <string>
// #include <cstring>
// #include <numeric>
// #include <functional>
// #include <cstdlib>
// #include <vector>
// #include <set>
// #include <map>
// #include <algorithm>
// #include <cmath>
// #include <iomanip>
using namespace std;
using i64 = long long;
#define lowbit(x) ((x) & -(x))
#define endl '\n'
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef long long ll;
// typedef long long i64;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T>
T power(T a, int b) {
	T res = 1;
	for (; b; b >>= 1, a = a * a) {
		if (b & 1) {
			res = res * a;
		}
	}
	return res;
}
template <typename T>
T Myabs(T a) {
	return a >= 0 ? a : -a;
}
template <typename T>
inline void read(T& x)
{
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - '0', ch = getchar(); }
	x *= f;
}
const int INF = 0x3f3f3f3f;
// const int mod = 1000000007;
const int mod = 998244353;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int sgn(double x) {
	return x < -eps ? -1 : x > eps;
}
/*
Tips:
   1.int? long long?
   2.don't submit wrong answer
   3.figure out logic first, then start writing please
   4.know about the range
   5.check if you have to input t or not
   6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/

void solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	i64 sum1 = 0, sum2 = 0;
	bool ok = false;
	for (int i = 0, j = n - 1; i < j; ) {
		if (a[i] + sum1 < sum2 + a[j]) {
			if (i + 1 > n - j) {
				ok = true;
				break;
			}
			else {
				sum1 += a[i];
				i++;
			}
		}
		else {
			sum2 += a[j];
			j--;
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
	return;
}
signed main() {
	IOS1;
	// IOS2;
#ifdef ONLINE_JUDGE
#else
	freopen("in.txt", "r", stdin);
#endif
	int __t = 1;
	cin >> __t;
	for (int _t = 1; _t <= __t; _t++) {
		solve();
	}
	return 0;
}
/*
25820
*/

Problem - C - Codeforces

要求n由不同的2的次方或者某数的阶乘组成,可以知道n的取值范围最多到14!,所以可以先枚举阶乘,再用c++的__builtin_popcountll()数一数剩下需要多少个2的次方,那么就是用14位来表示用谁的阶乘,0表示不用,1表示用,而且m只有大于等于0的时候才更新答案,小于0没意义

AC代码:

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include <iostream>
// #include <cstdio>
// #include <queue>
// #include <deque>
// #include <stack>
// #include <string>
// #include <cstring>
// #include <numeric>
// #include <functional>
// #include <cstdlib>
// #include <vector>
// #include <set>
// #include <map>
// #include <algorithm>
// #include <cmath>
// #include <iomanip>
using namespace std;
using i64 = long long;
#define lowbit(x) ((x) & -(x))
#define endl '\n'
#define IOS1 ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define IOS2 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef long long ll;
// typedef long long i64;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T>
T power(T a, int b) {
	T res = 1;
	for (; b; b >>= 1, a = a * a) {
		if (b & 1) {
			res = res * a;
		}
	}
	return res;
}
template <typename T>
T Myabs(T a) {
	return a >= 0 ? a : -a;
}
template <typename T>
inline void read(T& x)
{
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { x = x * 10 + ch - '0', ch = getchar(); }
	x *= f;
}
const int INF = 0x3f3f3f3f;
// const int mod = 1000000007;
const int mod = 998244353;
const double PI = acos(-1.0);
const double eps = 1e-6;
inline int sgn(double x) {
	return x < -eps ? -1 : x > eps;
}
/*
Tips:
   1.int? long long?
   2.don't submit wrong answer
   3.figure out logic first, then start writing please
   4.know about the range
   5.check if you have to input t or not
   6.modulo of negative numbers is not a%b, it is a%b + abs(b)
*/
i64 a[20];
void solve() {
	i64 n;
	cin >> n;
	int ans = INF;
	for (int i = 0; i < (1 << 14); i++) {
		i64 m = n;
		for (int j = 0; j < 14; j++) {
			if (i >> j & 1) {
				m -= a[j + 1];
			}
		}
		if (m >= 0) {
			ans = min(ans, __builtin_popcount(i) + __builtin_popcountll(m));
		}
	}
	cout << ans << endl;
	return;
}
signed main() {
	IOS1;
	// IOS2;
#ifdef ONLINE_JUDGE
#else
	freopen("in.txt", "r", stdin);
#endif
	a[0] = 1;
	for (int i = 1; i <= 14; i++) {
		a[i] = a[i - 1] * i;
	}
	int __t = 1;
	cin >> __t;
	for (int _t = 1; _t <= __t; _t++) {
		solve();
	}
	return 0;
}
/*
25820
*/

愿有那么一天,我也能六分钟签完div2的abc

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Codeforces Round #774 (Div. 2)(A-C) 的相关文章

  • HTML5 section、article和div区别

    在HTML5中 xff0c 规定开发过程中更加注重语义化和代码的结构标准 当中section article和div是非常相似的东西 xff0c 许多人无法区分它们 当初我对于这三个标签也很迷茫 xff0c 觉得都没什么区别 xff0c 用
  • Codeforces Round #588 (Div. 1)

    Contest Page 因为一些特殊的原因所以更得不是很及时 A sol 不难发现当某个人diss其他所有人的时候就一定要被删掉 维护一下每个人会diss多少个人 xff0c 当diss的人数等于剩余人数 1 的时候放队列里 xff0c
  • coderforces round 894(div.3)

    Problem A Codeforces AC代码 include
  • CSS 元素垂直居中的 6种方法

    转自 http blog zhourunsheng com 2012 03 css E5 85 83 E7 B4 A0 E5 9E 82 E7 9B B4 E5 B1 85 E4 B8 AD E7 9A 84 6 E7 A7 8D E6 9
  • 1800*D. Nested Segments(数组数组&&离散化)

    解析 按照右端点进行排序 这样某个区间包含的区间只能是在其前面的区间中 所以维护左端点 x 的出现次数 这样我们在查询某个区间 x y 的时候 只需要求 x y 之间包含多少个前面区间的 x 即可 前缀和 因为 前面区间的 y 显然小于当前
  • 1400*A. World Football Cup(模拟)

    Problem 19A Codeforces 解析 模拟 记录总得分 净胜球 进球数 坑点 其中注意净胜球是进球数的差 己方进球数 对手进球数 可以为负数 排序即可 include
  • Petya and Exam【Codeforces 1282 C】【贪心】

    Codeforces Round 610 Div 2 C 有N道题目 题目有简单与困难之分 简单的题目花费A分钟 困难的题目花费B分钟 那么考试时间一共有T的情况下 我们是可以提前交卷的 但是有些时间限制 就是譬如说你现在第x分钟交卷 但是
  • Codeforces Round #364 (Div. 2)【贪心、数学、尺取】

    Codeforces 701 A Cards 直接贪心即可 写法各异 include
  • jQuery 查找文本并高亮

    让我们来看一下如何使用 jQuery 去查找或搜索一段文本并高亮它 我是 jQuery 的忠实粉丝 喜欢它简介的语法 接下来让我演示一个示例 仅使用一行 jQuery 代码便可把搜索字段进行高亮
  • Daniel and Spring Cleaning【数位DP】【Codeforces 1245 F】

    Codeforces Round 597 Div 2 F 这道题化简一下就是让我们求有上下限的2进制数中有几对满足每一位的相 值不为1的对数 那么 首先看到这个1e9就会让人想到数位DP 然后接着就是如何去求的这样一个问题 我们不如将上下限
  • 1600*C. Binary String Copying

    https codeforces com problemset problem 1849 C Binary String Copying 洛谷 解析 对于某个区间x y 他排序之后 最左侧的连续0和最右侧的连续1是不影响排序结果的 假设左侧
  • [转]background-image属性研究

    http blog sina com cn s blog 4a0eab070100d8pk html 在设置background image属性时 经常会遇到一个background position 一直不怎么会用 今天有空研究下 版本
  • Codeforces Round #367 (Div. 2)【贪心、差分、DP、字典树、二维链表】

    Codeforces Round 367 Div 2 A Beru taxi 就是问 我们知道一个点 从其他点到它的最少花费的时间是多少 include
  • 1500*B. Coloring(找规律&鸽巢原理)

    include
  • 1600*B. Jumping Jack(数学&&找规律)

    解析 一直往右条 直到第一次超过 x 如果当前和目标点 p x为偶数 则 p x 2 的那一步向左跳 这样会少跳 p x 正好补在多跳的这一段 如果为奇数 则不能除2 则继续跳 直到距离为偶数即可 x和x答案一样 include
  • codeforces 733D--Kostya the Sculptor

    Description Kostya is a genial sculptor he has an idea to carve a marble sculpture in the shape of a sphere Kostya has a
  • 网站开发之DIV+CSS简单布局网站入门篇(五)

    这篇文章主要介绍如何使用DIV和CSS简单布局一个网站的首页 通常将网站划分为顶部 Logo 导航条 中部 页面主要内容 左右栏目 底部 制作方介绍 超链接 这是非常基础的一篇引入性文章 采用案例的方式进行介绍的 希望对你有所帮助 运行结果
  • 用jquery实现选项卡效果(非常漂亮,带动画效果)

  • Puzzles【Codeforces 697 D】【树形DP + 期望DP】

    Codeforces Round 362 Div 2 D 我们从1号结点开始 给每个结点标序 问的是每个结点的序号的期望是多少 输出这N个结点的期望 那么1号点的期望一定就是1了 对于其他的点呢 可以举例这样的一幅图 首先我们可以确定1 因
  • Codeforces 1475C. Ball in Berland(二元容斥)

    题目传送门 题意 一个班级有a个男生和b个女生 现在这个班级有k对男女愿意一起出席毕业典礼 这里注意k对男女中可能会有某个男生或女生出现在多个pair中 你从这k对中找出两对 使得这两对中的男生不相同 女生不相同 即一个男生或女生不可能在一

随机推荐

  • Pytorch用自己的数据训练ResNet

    一 ResNet算法介绍 残差神经网络 ResNet 是由微软研究院的何恺明等人提出的 ResNet 在2015 年的ILSVRC中取得了冠军 通过实验 xff0c ResNet随着网络层不断的加深 xff0c 模型的准确率先是不断的提高
  • 新装Ubuntu系统基本环境安装配置(conda)

    Ubuntu系统用conda来配置深度学习环境 1 配置显卡驱动 查看显卡驱动 nvidia smi 如果是这个命令没有反应 xff0c 就是没有显卡驱动 xff0c 这个时候要先安装显卡驱动 然后再安装cuda xff0c 在这个图中 x
  • Python源码加密与Pytorch模型加密

    0 前言 深度学习领域 xff0c 常常用python写代码 xff0c 而且是建立在一些开源框架之上 xff0c 如pytorch 在实际的项目部署中 xff0c 也有用conda环境和python代码去部署服务器 xff0c 在这个时候
  • Paddle-Lite终端部署深度学习模型流程

    Paddle Lite是飞桨基于Paddle Mobile全新升级推出的端侧推理引擎 xff0c 在多硬件 多平台以及硬件混合调度的支持上更加完备 xff0c 为包括手机在内的端侧场景的AI应用提供高效轻量的推理能力 xff0c 有效解决手
  • nohup: failed to run command `java': No such file or directory

    问题描述 xff1a 平台研发项目 xff0c ActiveQM做消息队列 xff0c zookeeper做集群 xff0c zkui做可视化服务管理 xff0c skynet是引擎服务 xff0c skynet下面有一个xmanager是
  • 【原理篇】一文读懂Faster RCNN

    0 Faster RCNN概述 论文地址 xff1a https arxiv org pdf 1506 01497 pdf Faster R CNN源自2016年发表在cs CV上的论文 Faster R CNN Towards Real
  • 【原理篇】一文读懂Mask RCNN

    Mask RCNN 何凯明大神的经典论文之一 xff0c 是一个实例分割算法 xff0c 正如文中所说 xff0c Mask RCNN是一个简单 灵活 通用的框架 xff0c 该框架主要作用是实例分割 xff0c 目标检测 xff0c 以及
  • 【原理篇】一文读懂FPN(Feature Pyramid Networks)

    论文 xff1a feature pyramid networks for object detection 论文链接 xff1a https arxiv org abs 1612 03144 这篇论文是CVPR2017年的文章 xff0c
  • pytorch用voc分割数据集训练FCN

    语义分割是对图像中的每一个像素进行分类 xff0c 从而完成图像分割的过程 分割主要用于医学图像领域和无人驾驶领域 和其他算法一样 xff0c 图像分割发展过程也经历了传统算法到深度学习算法的转变 xff0c 传统的分割算法包括阈值分割 分
  • 【学习笔记】语义分割综述

    语义分割就是图像分割 xff0c 是图像像素级的分类 xff0c 即给图像的每一个像素点分类 与之临近的一个概念叫实例分割 xff0c 实例分割就是语义分割 43 目标检测 语义分割只能分割出所有同类的像素 xff0c 目标检测把不同的个体
  • pytorch用自己数据集训练Unet

    在图像分割这个问题上 xff0c 主要有两个流派 xff1a Encoder Decoder和Dialated Conv 本文介绍的是编解码网络中最为经典的U Net 随着骨干网路的进化 xff0c 很多相应衍生出来的网络大多都是对于Une
  • 【史上最全】重装ubuntu20.04系统基本环境配置

    最近新买电脑重装ubuntu玩深度学习 xff0c 踩了两天坑总结处下列流程 一 重装系统 xff08 U盘方式 xff09 ubuntu20 04镜像文件下载地址 Ubuntu 20 04 4 Desktop 64 bit 在ubuntu
  • PaddleDetection2.x训练、部署自己的模型

    PaddleDetection是百度Paddle家族的一个目标检测开发套件 个人感觉Paddle的优点是模型比较丰富 xff0c 支持的部署方式较多 xff08 python C 43 43 移动端等 xff09 xff0c 缺点是坑比较多
  • TensorRT(C++)部署 Pytorch模型

    众所周知 xff0c python训练pytorch模型得到 pt模型 但在实际项目应用中 xff0c 特别是嵌入式端部署时 xff0c 受限于语言 硬件算力等因素 xff0c 往往需要优化部署 xff0c 而tensorRT是最常用的一种
  • 安卓端使用ncnn部署yolov5(v6.0)

    ncnn是腾讯公司开源的一个专为手机端极致优化的高性能神经网络前向计算框架 ncnn从设计之初 xff0c 就深刻考虑手机端的部署和使用 xff0c 无需第三方依赖 xff0c 跨平台 xff0c 手机端cpu的速度快于目前所有已知的开源框
  • 软件工程本科毕业设计题目推荐?软件工程毕设题目大全

    软件工程本科毕业设计题目推荐 xff1f 这个的话首先你对那些方面比较熟悉 xff0c 毕竟软件工程范围还是比较广的 xff0c 所以这个你得要自己确定好方向 xff0c 这个很重要 首先软件工程专业可以做网站 xff0c 系统 xff0c
  • 人工智能论文猜想

    一 前言 人类是不是机器人 随着时代的进步 xff0c 人工智能诞生了 又随着人工智能的进步 xff0c ChatGPT诞生了 xff0c 这不仅让我想出一个问题 xff1a 我们人类是不是机器人 xff1f ChatGPT xff0c 发
  • 机器学习线性分类

    数学模型 分类的目标是把输入 x 匹配到唯一的离散型类别 Ck 中 在一个平面中 xff0c 我们可以用一条直线分开两组数据 xff0c 所以这条直线 xff0c 一般来讲是在D维输入空间中的 xff08 D 1 xff09 维超平面 xf
  • marlin2.0 的使用过程记录。skr v1.3

    硬件 tb购入 xff0c 主控是LPC1768 xff0c 32位的 软件 软件下载地址 https github com bigtreetech BIGTREETECH SKR V1 3 这个git库是skr板子的商家维护的 xff0c
  • Codeforces Round #774 (Div. 2)(A-C)

    Problem A Codeforces 签到题 xff0c 判断s里面最多能够有多少个 AC代码 pragma GCC optimize 2 pragma GCC optimize 3 pragma GCC optimize 34 Ofa