HDU 3709 Balanced Number

钉钉微应用免登实战:Java服务端与H5全链路接入指南 在企业移动办公场景中,身份认证是H5系统与钉钉工作台打通的第一道关卡。传统账号密码登录在移动端体验割裂,而免登通过钉钉客户端已完成的安全认证,以一次性授权码(authCode)为凭证,由Java服务端换取钉钉用户身份并签发自有会话,实现从工作台到H5首页的无感跳转。其核心价值在于兼顾安全性与体验:前端不接触敏感密钥,服务端统一管控access_token缓存与用户映射。这一机制广泛适用于企业内部OA、报表、工单等微应用,能显著降低重复登录带来的用户流失。文章围绕钉钉免登的完整链路,详解Java接口实现、H5 阅读详情

Balanced Number

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)
Total Submission(s): 2161    Accepted Submission(s): 960


Problem Description
A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. When a pivot is placed at some digit of the number, the distance from a digit to the pivot is the offset between it and the pivot. Then the torques of left part and right part can be calculated. It is balanced if they are the same. A balanced number must be balanced with the pivot at some of its digits. For example, 4139 is a balanced number with pivot fixed at 3. The torqueses are 4*2 + 1*1 = 9 and 9*1 = 9, for left part and right part, respectively. It's your job
to calculate the number of balanced numbers in a given range [x, y].
 

Input
The input contains multiple test cases. The first line is the total number of cases T (0 < T ≤ 30). For each case, there are two integers separated by a space in a line, x and y. (0 ≤ x ≤ y ≤ 10 18).
 

Output
For each case, print the number of balanced numbers in the range [x, y] in a line.
 

Sample Input
  
2 0 9 7604 24324
 

Sample Output
  
10 897
 

Author
GAO, Yuan
 

Source
 

Recommend
zhengfeng   |   We have carefully selected several similar problems for you:   3711  3715  3718  3713  3712 
 

Statistic |  Submit |  Discuss |  Note

数位DP,可以参考本博客另外两篇博文:

HDU 2089 不要62

HDU 3652 B-number

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;

//dp[i][j][k],i表示位数,j表示去掉的点的位置,k表示两遍数的计算结果的差
LL dp[20][20][2500];
int num[50];
LL dfs(int pos,int center,int cha,bool limit)
{
    if(pos==0) return cha==0;//结果差为0则返回1
    if(cha<0) return 0;
    if(!limit && dp[pos][center][cha]!=-1) return dp[pos][center][cha];
    int end = limit?num[pos]:9;
    LL ans = 0;
    for(int i = 0;i <= end;i++)
    {
        ans+=dfs(pos-1,center,cha+i*(pos-center),limit&&(i==end));
    }
    if(!limit)
        dp[pos][center][cha] = ans;
    return ans;
}
LL work(LL n)
{
    int len = 0;
    while(n)
    {
        num[++len] = n%10;
        n/=10;
    }
    LL ans = 0;
    for(int i = 1;i <= len;i++)
    {
        ans+=dfs(len,i,0,true);
    }
    return ans-len+1;
}
int main()
{
    int T;
    scanf("%d",&T);
    LL a,b;
    while(T--)
    {
        memset(dp,-1,sizeof(dp));
        scanf("%I64d %I64d",&a,&b);
        printf("%I64d\n",work(b)-work(a-1));
    }
    return 0;
}


DFT实训教程笔记2(bibili版本)- Scan synthesis practice 文章目录Scan synthesis practice 本博文是博主记录DFT实训教程的笔记版本,此笔记并没有对所有的知识进行记录,仅仅以自身的认知水平,来记录了一些部分笔记并加上了自己的理解。 Scan synthesis practice How to design scan clock structure? 假设一块chip里面有好几十个clock domain,如果每一个clock domain都用一个scan clock虽然会非常清晰,但是IO数目肯定不够用。 clock group: 1、no 阅读详情

相关推荐

Ubuntu20.04系统Cuckoo sandbox所需环境搭建及安装(超详细图文)

请勿叫我大神,我只是互联网的搬运工~ 前言 本教程以Ubuntu20桌面版作为示范,服务器版同样适用,但可能稍微麻烦一点,服务器版本的话安装Xmanage套装使用可能会相对轻松一些,由于后面会使用到vbox的使用,对vbox命令行操作不熟悉的小伙伴用xmanage可能会相对轻松一点。 提示:以下是本篇文章正文内容,下面案例可供参考 安装ubuntu20桌面版 步骤1:转到https://ubuntu.com/download/desktop下载下载.iso。 步骤2:使用您选择的虚拟机监控程序(VMWa

ElsonHY的博客 1万+

Balanced Number(数位DP)

D - Balanced Number HDU - 3709 A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indica...

weixin_30871293的博客 159

Apache Doris集群IP变更急救指南:用Docker容器+priority_networks快速恢复FE/BE节点

本文详细介绍了Apache Doris集群在IP变更情况下的应急处理方案,通过Docker容器和priority_networks配置快速恢复FE/BE节点。文章提供了从容器化环境构建、元数据迁移到生产环境切换的全流程指南,帮助运维团队在30分钟内完成集群恢复,显著减少停机时间。

pink7的博客 114

Balanced Number (数位dp)

A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated by the digit. When a pivot is ...

永夜莫明的博客 346

决策大模型与生成式大模型有何不同?一文拆解技术框架与落地路径

大模型技术正从内容生成走向复杂场景的智能决策。与生成式大模型拟合概率分布不同,决策大模型以序列决策为核心,融合强化学习机制,在动态环境中感知反馈、持续修正行动路径。其技术框架涵盖语义理解、规划推理与闭环决策,并通过世界模型进行低成本仿真推演,显著提升供应链调度、物流排程等场景的应对效率。实际落地时需结合传统优化算法与人工兜底,构建“语义先导+数值寻优”的分层架构,才能平衡精度与稳定性。这篇内容拆解决策大模型的技术组成、落地路径与常见误区,为企业智能化转型提供可参考的实践框架。

weixin_29057163的博客 189

基于单片机控制双向可控硅灯光强度设计

*单片机设计介绍,基于单片机控制双向可控硅灯光强度设计。

QQ2193276455的博客 2457

Balanced Number(数位dp,枚举平衡点)

题目链接 大意:平衡数有平衡点,使平衡点两边的权值(数值)×权重(到平衡点的距离)和相等 对于任意一个平衡数,它的平衡点唯一 枚举平衡点统计平衡数的个数 注意0的情况,0有一个平衡点,但是00有两个平衡点,000有三个平衡点 #include &lt;bits/stdc++.h&gt; #define ll long long using namespace std; ll dp[20]...

蒟蒻 lxw的博客 564

TDISP(TEE Device Interface Security Protocol)软件操作流程

/ 1. SPDM会话相关定义(🔶1-37、🔶1-187)// SPDM会话ID// AES-256-GCM加密密钥(TDISP要求)// 初始向量// 会话是否激活// 2. IDE流配置(🔶1-52、🔶1-625)// IDE流ID// 4个子流的AES密钥(覆盖所有子流类型)// 密钥是否已配置// 3. TDI状态与配置(🔶1-207、🔶1-210)TDI_CONFIG_UNLOCKED = 0, // 初始配置态。

inquisiter 1435

Balanced Number [数位DP]

题意:一个数字是Balanced number当且仅当存在一个位置loc,使得一个数字的pos位置上的数字dig_pos*(pos-loc)的和是0。 询问区间内有多少这样的数字。 采用数位DP的方法,对于每一个位置,保存状态dp[pos][loc][sum]表示当前位pos位,中心位置为loc,前面的累加和为sum的状态的答案。 执行call()函数的时候,对于一个区间,loc从1到len遍

Qer的博客 496

第14.1章 高翔博士2025年11月最新开源框架Lightning-LM源码学习解读(一):激光-IMU定位+建图算法各模块简介

Lightning-LM:高效激光SLAM定位系统 该框架基于模块化设计,通过激光-IMU融合实现快速建图与定位,核心特点包括: 极速性能:纯CPU运行(建图1.2核/定位0.8核) 模块化架构:包含激光里程计(LIO)、地图管理、回环检测等独立模块 动态场景支持:地图分块加载、动静态图层分离 多模式适配:支持ROS2环境下的在线/离线运行 关键模块包括前端里程计(core/lio)、2D/3D地图转换(core/g2p5)、轻量优化库(core/miao)等,通过系统控制器(core/system)协调流

行知SLAM 2439

lammps案例:聚乙烯和石墨烯界面pull out模拟

大家好,我是小马老师。 本文介绍lammps模拟计算界面结合力的一个案例。 本案例参考论文《The interfacial mechanical properties of functionalized graphene- polymer nanocomposites》,对论文作者表示感谢。 模型共分2层,上层为聚乙烯模型,下次为单层石墨烯,模拟过程共分3部分:建模、弛豫、拉伸。 (1)建模 使用MS建立聚乙烯和石墨烯模型,具体方法可参考之前的推文,使用build layer方法建立聚乙烯和石墨烯组合模型,

lammps_jiayou的博客 3496

hdu 3709 Balanced Number

个人练习记录

m0_73500785的博客 957

Pandas滚动窗口的妙用:动态计算列数据的最大值

Pandas的滚动窗口(rolling window)功能是数据分析中处理时间序列数据的重要工具。本文通过实例演示了如何使用rolling(window=4).max()计算DataFrame列A的滚动最大值,并将结果存入新列Max_Range。该方法会在4个元素的滑动窗口内计算最大值,前3行因数据不足显示为NaN。这种技术广泛应用于金融分析(如股价波动)、数据平滑和趋势识别等场景,能有效帮助分析数据的动态变化特征。示例展示了从数据准备到结果输出的完整流程,体现了Pandas在处理滑动窗口计算时的高效性和便

m0_74337424的博客 53

Balanced Number HDU - 3709

http://acm.hdu.edu.cn/showproblem.php?pid=3709 dp[i][j]代表[i+1,pos-1]的权值和为j时 [0,i]能提供多少解 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef l...

sunyutian1998的博客 143

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

HDU-3709 Balanced Number

Balanced Number Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Problem Description A balanced number is a non-negative integer that can be balanced if a pi

JSure的代码库 850

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

hdu3709 Balanced Number 数位dp

hdu3709 Problem Description A balanced number is a non-negative integer that can be balanced if a pivot is placed at some digit. More specifically, imagine each digit as a box with weight indicated b...

__surtr的博客 198

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

hdu-3709 Balanced Number

Balanced Number Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 65535/65535 K (Java/Others) Problem Description A balanced number is a non-negative integer that can be balanced if a...

aln1541的博客 190

【HDU3709】 Balanced Number

一开始想到的是f[len][pivot][j][k]记录到len,支点为pivot,左边j,右边k的值 看过题解后发现可以直接记录j-k为power_matrix,这样可以少一维,还可以在为负数时剪枝。

Lhq 280

HDU3709 Balanced Number

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3709 题目大意:   定义一个数字上的某一个数位作为中枢,其他数位上的数乘上该数位到中枢的距离称为该数位上的权值。   问在 \([x,y]\) 中满足下述条件的数有多少个:   即能够在数字上任取一个数位作为中枢,使得中枢左右所有数位的权值和相等。 知识点:  数位DP 解题思...

dielie6462的博客 185

hdu 3709 balanced number【数位dp】

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3709 题目大意:找出 [L , R]区间内是balanced number 的个数; balacced numbe定义:数字中有个平衡点,使两边的数字乘距离平衡点的距离的和相等,例如 4139,把3看作平衡点 左边4*2+1*1 = 右边 9*1; 思路:枚举每一个平衡点,进行数位dp,得出的an...

几许情愁的博客 226

HDU - 3709 Balanced Number 数位dp

题目链接:https://vjudge.net/problem/HDU-3709 题意:有多少平衡数,例如:4139 is a balanced number with pivot fixed at 3. The torqueses are 4*2 + 1*1 = 9 and 9*1 = 9, 题解:所以每个数的平衡位置只能有一个 dp[ i ][ j ][ k ][ z ] 表示 平衡位置...

还我笑颜 183

Hdu 3709 Balanced Number

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3709 记忆化 ,用的数位dp的模式感觉 ,数位dp也是菜开始学的 感觉很难看了一些博客 最终艰难的把它a了,写个题解来巩固一下把尽量写得详细点。 网上很多博客都说直接枚举支点 其实对这个不是很熟,下面就用我的话来表述一下这个题吧。 首先是暴力dfs,对于指定长度的一个数,小于它的数有多少是平横数

touwangyi的博客 258
上一篇: HDU 3652 B-number
下一篇: 高斯消元模板(kuangbin大神版本)
New-Spirit
博客等级 码龄14年 13粉丝 138原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值