简单二分。

思路

数位 dp 预处理和判断。

init 预处理出 dp 数组,与 windy 数大致相同。

二分答案,如果 111 至 midmidmid 的 Neq 数数量大于等于 kkk,rt=midrt=midrt=mid;否则 lt=midlt=midlt=mid,最后输出 rtrtrt。

query 直接当 check 用。

AC code:

#include<bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
int dp[100][100];
int l,r;
void init(){
for(int i=0;i<=9;i++){
dp[1][i]=1;
}
for(int i=2;i<=19;i++){
for(int j=0;j<=9;j++){
for(int k=0;k<=9;k++){
if(j!=k){
dp[i][j]+=dp[i-1][k];
}
}
}
}
}
int query(int x){
if(x==0){
return 0;
}
int num[25],cnt=0,ans=0;
while(x!=0){
cnt++;
num[cnt]=x%10;
x/=10;
} for(int i=cnt;i>=1;i--){
for(int j=0;j<num[i];j++){
if(i==cnt&&j==0)continue;
if(i!=cnt&&num[i+1]==j)continue;
ans+=dp[i][j]; }
if(i!=cnt&&num[i]==num[i+1])break;
if(i==1)ans++;
}
for(int i=cnt-1;i>=1;i--){
for(int j=1;j<=9;j++){
ans+=dp[i][j];
}
}
return ans;
}
signed main(){
init();
int t,k;
cin>>t;
while(t--){
cin>>k;
int lt=-1,rt=1e15+1;
while(lt+1!=rt){
int mid=(lt+rt)/2;
if(query(mid)>=k){
rt=mid;
}
else{
lt=mid;
}
}
cout<<rt<<endl;
} return 0;
}

题解:AT_arc173_a [ARC173A] Neq Number的更多相关文章

  1. 题解-Ehab's REAL Number Theory Problem

    Ehab's REAL Number Theory Problem 前置知识 质数 分解质因数 无向无权图最小环<讲> Ehab's REAL Number Theory Problem/ ...

  2. LeetCode题解之Valid Triangle Number

    1.题目描述 2.问题分析 暴力计算 3.代码 int triangleNumber(vector<int>& nums) { ; ) return res; ; i < n ...

  3. PAT甲题题解-1019. General Palindromic Number (20)-又是水题一枚

    n转化为b进制的格式,问你该格式是否为回文数字(即正着写和倒着写一样)输出Yes或者No并且输出该格式又是水题... #include <iostream> #include <cs ...

  4. PAT甲题题解-1104. Sum of Number Segments (20)-(水题)

    #include <iostream> #include <cstdio> #include <algorithm> #include <string.h&g ...

  5. C#版(打败97.89%的提交) - Leetcode 202. 快乐数 - 题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - L ...

  6. LeetCode Graph Valid Tree

    原题链接在这里:https://leetcode.com/problems/graph-valid-tree/ 题目: Given n nodes labeled from 0 to n - 1 an ...

  7. 【codeforces 796A】Buying A House

    [题目链接]:http://codeforces.com/contest/796/problem/A [题意] 让你选一个最靠近女票的,且能买的房子; 输出你和你女票的距离; [题解] 枚举 [Num ...

  8. Codeforces #144 (Div. 1) B. Table (组合数学+dp)

    题目链接: B.Table 题意: \(n*m\)的矩阵使每个\(n*n\)矩阵里面准确包含\(k\)个点,问你有多少种放法. \((1 ≤ n ≤ 100; n ≤ m ≤ 10^{18}; 0 ≤ ...

  9. 【Leetcode 做题学算法周刊】第四期

    首发于微信公众号<前端成长记>,写于 2019.11.21 背景 本文记录刷题过程中的整个思考过程,以供参考.主要内容涵盖: 题目分析设想 编写代码验证 查阅他人解法 思考总结 目录 67 ...

  10. C#版 - Leetcode 414. Third Maximum Number题解

    版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. C#版 - L ...

随机推荐

  1. Linux部署Python项目

    项目部署 项目部署对于操作通常是由运维人员来进行统一管理装配的,但是对于一个开发人员来讲,基础的项目部署还是要会的. 这里我主要讲解python的项目是如何部署的,至于项目哪里来的,这就要看观众如何抉 ...

  2. 定制Allure报告

    定制Allure报告 自定义Logo图标 效果图 实现步骤 定位资源文件夹:首先,您需要定位到 allure/plugins/custom-logo-plugin/static 文件夹.这个文件夹通常 ...

  3. 为什么TCP需要三次握手?深入解析背后的设计哲学

    在互联网通信中,TCP(传输控制协议)是确保数据可靠传输的基石.而TCP连接的建立过程--"三次握手"(Three-Way Handshake),看似简单的三个步骤,却蕴含了网络协 ...

  4. flutter-解决长按TextField出现英文(复制粘贴)问题

    第一步 引入依赖 dependencies: flutter: sdk: flutter flutter_localizations: sdk: flutter 第二步 在main.dart中添加代码 ...

  5. 基于Trae开发的自动表关联查询工具

    对于复杂的一些业务,会涉及很多张表,其间有各种各样的关联关系,在开发&测试过程中,随时需要查看这些表中的数据状态,这种情况下需要我们写一些关联查询的SQL或者多条SQL执行来查看结果,个人感觉 ...

  6. 傻妞教程——对接QQ机器人go-cqhttp

    原本我懒,用的傻妞QQbot一键安装版,docker的,最近有点问题,索性换了go-cqhttp 安装go-cqhttp: go-cqhttp项目地址:https://github.com/Mrs4s ...

  7. 记录:tinyrenderer---1.2 Rasterizing the boundary

    光栅化三角形 Scanline rendering(扫描线渲染),一个老式的算法 按y轴坐标进行排序,我这里采取降序,ay > by > cy 同时光栅化三角形的左右两边 绘制水平线段,连 ...

  8. 如何基于大语言模型和MaxKB实现PPT自动生成方案

    一.实现方案 利用讯飞大模型智能 PPT 生成接口实现,具体参见:讯飞开放平台智能PPT生成 https://www.xfyun.cn/services/aippt#anchor4503211 二.新 ...

  9. java如何实现对List集合进行分页

    对List集合进行分页: private <T> Page<T> listToPage(List<T> dataList, Integer pageSize, In ...

  10. vue2打包部署到nginx,解决路由history模式下页面空白问题

    项目使用的是vue2,脚手架vue-cli 4. 需求:之前项目路由使用的是hash,现在要求调整为history模式,但是整个过程非常坎坷,遇到了页面空白问题.现在就具体讲一下这个问题. 首先,直接 ...