[ABC321C] 321-like Searcher
Problem
题目简述
给你一个 \(K\),求出 \([1 \sim K]\) 区间内有多少个 321-like Number。
321-like Number 的定义:
- 每一位上的数字从左到右严格单调递减。
- 或者说,若它有 \(d\) 位,对于 \(\forall i\in[1,d-1]\),从左到右第 \(i\) 位上的数大于从左到右第 \(i+1\) 位上的数。
思路
预处理出所有的 321-like Number,枚举的时候类似枚举集合的做法。
存到 vector 数组里,排序后输出第 \(K\) 大的。
【注意】 本题需要开 \(\text{long long}\)。
代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; // 开long long
ll k;
int main() {
scanf("%lld", &k);
k--;
vector<ll> v; // vector 存放枚举的结果
for (int i = 2; i < (1 << 10); i++) {
ll t = 0;
for (int j = 9; j >= 0; j--) {
if ((i >> j) & 1) { // 这一位为不为0
t *= 10, t += j; // 加到结果里
}
}
v.push_back(t);
}
sort(v.begin(), v.end()); // 排序
printf("%lld", v[k]); // 输出结果
return 0;
}
[ABC321C] 321-like Searcher的更多相关文章
- solr searcher
solr searcher 前面我配置好了solr,并且数据库建立索引也完成了. 为php添加搜索 首先下载solrphp http://wiki.apache.org/solr/SolPHP 在so ...
- centos7 下手动安装MySQL-5.6.32-1.linux_glibc2.5.x86_64.rpm-bundle
由于centos7默认不再是mysql数据库,所以度算手动安装一个. 全程参考http://www.2cto.com/database/201501/371451.html 这里摘抄以下这个链接的内容 ...
- COMP 321
COMP 321April 24, 2019Questions on this exam may refer to the textbook as well as to the manual page ...
- 402. Remove K Digits/738.Monotone Increasing Digits/321. Create Maximum Number
Given a non-negative integer num represented as a string, remove k digits from the number so that th ...
- SCUT - 321 - Tobby's magic - 线段树
https://scut.online/p/321 第一次做区间线段树. 感觉和单点的一样啊.pushdown的时候要注意一些问题,st的值有可能是跟区间长度有关的. #include<bits ...
- 321. Create Maximum Number 解题方法详解
321. Create Maximum Number 题目描述 Given two arrays of length m and n with digits 0-9 representing two ...
- Android Weekly Notes Issue #321
Android Weekly Issue #321 August 5th, 2018. Android Weekly Issue #321 本期内容包括: 开源项目Plaid的改版; 使用Tensor ...
- sgu 321 The Spy Network (dfs+贪心)
321. The Spy Network Time limit per test: 0.5 second(s)Memory limit: 65536 kilobytes input: standard ...
- 321. Create Maximum Number
/* * 321. Create Maximum Number * 2016-7-6 by Mingyang */ public int[] maxNumber(int[] nums1, int[] ...
- SGU - 321 - The Spy Network
先上题目: 321. The Spy Network Time limit per test: 0.5 second(s)Memory limit: 65536 kilobytes input: st ...
随机推荐
- Android文本编辑框点击弹出选择日期框
前言: 个人Android小白,写到这了,就记录一下,希望可以帮助到大家. Android输入框点击弹出日期选择框 // 获取 文本编辑框控制权 EditText returnTime = findV ...
- 【译】Visual Studio 2022 中的 Web API 开发
在 Visual Studio 2022 中,Web 开发人员的主要场景之一是使用 ASP.NET Core 创建 Web API.在 Visual Studio 2022 17.6 的最新预览版中, ...
- Robot Framework 自动化测试随笔(二)
二.Web自动化(1) 1.安装selenium2library库 pip install robotframework-selenium2library 2.指定报告的生成路径 在[Run]标签 ...
- enumerate()使用方法
enumerate()(单词意思是枚举的意思)是python中的内置函数, enumerate(X,[start=0]) 函数中的参数X可以是一个迭代器(iterator)或者是一个序列, start ...
- 绕过网站CDN查找网站真实ip方法大全(持续更新中)
这是一篇全网(无论国内还是国外)最全.最详细.最新.最实用的关于 CDN 网络对抗攻击的文章,渗透测试中若碰到 CDN 类的问题,只需要看这一篇指南即可.我也会在 Github (https://gi ...
- 论文解读(APCA)《Adaptive prototype and consistency alignment for semi-supervised domain adaptation》
[ Wechat:Y466551 | 付费咨询,非诚勿扰 ] 论文信息 论文标题:Adaptive prototype and consistency alignment for semi-super ...
- Node.js安装中出现的问题及其解决方案
Node.js安装与配置流程,请参考 1.npm -v测试时出现警告 更好的选择是安装一个更完善的版本 问题出现的原因 node更新后是最新版 但是npm的版本没有相应的更新存在版本滞后导致问题出现 ...
- 一种基于ChatGPT的高效吃瓜方式的探索和研究。
你好呀,我是歪歪. 最近掌握了一个新的吃瓜方式,我觉得还行,给大家简单分享一下. 事情说来就话长了,还得从最近的一次"工业革命"开始,也就是从超导材料说起. 8 月 1 日的时候 ...
- LabVIEW图形化TensoRT工具包的安装下载分享
前言 Hello,大家好,我是virobotics(仪酷智能)今天我们一起来看一下如何安装[LabVIEWTensoRT工具包]. 一.LabVIEW图形化TensoRT工具包简介 工具包特点: 图形 ...
- 关于 LLM 和图数据库、知识图谱的那些事
本文整理自 NebulaGraph 布道师 wey 在「夜谈 LLM」主题分享上的演讲,主要包括以下内容: 背景 LLM RAG Graph 知识抽取 Text2Cypher Graph RAG 未来 ...