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) 的相关文章

  • 1603A - Di-visible Confusion

    1603A Di visible Confusion 题目 一个长度为N的数组从a1 a2 an 如果在存在不能被整除则可以删除 剩下的数变为a1 a2 an 1 求是否能使得数组为空 题解 每个数都会因为前一个数被删除而前移 所以遍历所有
  • C. Doremy‘s IQ(二分/贪心)

    题目 题意 给定n个任务和艾米的智商q 艾米要按顺序处理这n个任务 每个任务有难度值a i 对于每个任务 艾米可以选择处理 也可以选择不处理 如果艾米当前的智商q大于等于任务a i 则艾米可以直接处理该任务 智商不受任何影响 如果艾米当前的
  • 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
  • Codeforces Round 744 (Div. 3)

    A Casimir s String Solitaire 一个A需要一个B一个C需要一个B 所以只要A和C的个数之和等于B即可 AC代码 include
  • 1200*C. Stripe

    题意翻译 给定一整数n 下面有n个数a i 求将该数列分割成两个非空数列且两个数列内数字的和相等的方案数 1 lt n lt 10 5 a i 的绝对值不大于10000 解析 前缀和 include
  • Codeforces Round #364 (Div. 2)【贪心、数学、尺取】

    Codeforces 701 A Cards 直接贪心即可 写法各异 include
  • Codeforces Round #808 (Div. 2)C - Doremy‘s IQ

    C Doremy s IQ time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output D
  • 动态动态规划(DDP)

    1 Problem E Codeforces 一 题目大意 给你一个无向图 第i和i 1条边的权值是w i 问你每个点不在自己原本的点的代价是多少 会有q组询问 表示修改第i条边的权值 二 解题思路 可以观察到 完成这个操作需要每条边经过两
  • [转]background-image属性研究

    http blog sina com cn s blog 4a0eab070100d8pk html 在设置background image属性时 经常会遇到一个background position 一直不怎么会用 今天有空研究下 版本
  • Codeforces Round #553 (Div. 2)

    A Maxim and Biology time limit per test 1 second memory limit per test 256 megabytes input standard input output standar
  • Catowice City【Codeforces 1248 F】【BFS】

    Codeforces Round 594 Div 2 F 一开始是听闻有人说这是一道Tarjan好题 然后就点进来做了 但是想来想去 却想了个另类的法子 我们可以看到 如果N个人都要选择的话 那么每个人都只能是审判者 或者是参赛者 所以 我
  • 【CSS】css样式控制div水平垂直居中的六种方法

    1 绝对定位方法 不确定当前div的宽度和高度 采用 transform translate 50 50 当前div的父级添加相对定位 position relative 如图所示 代码如下 div background red posit
  • Codeforces Round#808 div.1+div.2题解

    视频讲解 BV1ya411S7KF div 2 A Difference Operations 题目大意 给定长度为 n n n 的数组 a a a 可以进行任意次操作 每次操作选择一个整数
  • 【前后缀 + 推公式整理】 Codeforces Round #813 (Div. 2) D. Empty Graph

    题意 给定 n n n 个点的点权 a i a i ai 这 n
  • 1400*C. No Prime Differences(找规律&数学)

    解析 由于 1 不是质数 所以我们令每一行的数都相差 1 对于行间 分为 n m之中有存在偶数和都为奇数两种情况 如果n m存在偶数 假设m为偶数 如果都为奇数 则 include
  • 网站开发之DIV+CSS简单布局网站入门篇(五)

    这篇文章主要介绍如何使用DIV和CSS简单布局一个网站的首页 通常将网站划分为顶部 Logo 导航条 中部 页面主要内容 左右栏目 底部 制作方介绍 超链接 这是非常基础的一篇引入性文章 采用案例的方式进行介绍的 希望对你有所帮助 运行结果
  • gym 101505 CTU Open Contest 2016 G Orchard Division

    Problem codeforces com gym 101505 attachments vjudge net contest 187874 problem G Meaning 一个 m m 的网格 长 宽下标 0 m 1 里有 n 个点
  • innerHTML 用法

    用法 比如在中写了如下的代码 div div 现在用top innerHTML 的方法就可以向这个id的位置写入HTML代码了 例如top innerHTML
  • 【codeforces】 ZeptoLab Code Rush 2015 A,B,C,D,E题解

    D E统统FST 差一点就飞升了 A King of Thieves 给你一张地图 让你从某个 开始跳等步长的四次 如果均在 则输出yes 否则输出no 枚举起始点和步长直接做就可以了
  • 简短的 mouseover 显示与隐藏层的办法

    简短的 mouseover 显示与隐藏层的办法 在制作 mouseover 和 mouseout 显示 隐藏层的时候 有时总会出现 mouseover 层里面的对象时 层消失的情况 这是因为mouseover 层内 对象时 会对前层产生两个

随机推荐

  • 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