#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
#define ll long long
#define maxn 100050
int ok(ll n){
for(ll i=n/*;i<=n;i++){
ll sum = ,tmp = i;
while(tmp){
sum += tmp%;
tmp /= ;
}
if(sum% == ){
return ;
}
}
return ;
}
ll f(ll n){
if(ok(n)){
return (n/) + ;
}
return n/;
}
int main(){
int T;
cin >> T;
for(int t=;t<=T;t++){
ll n,m;
cin >> n >> m;
printf("Case #%d: %lld\n",t,f(m)-f(n-));
}
return ;
}

Good Numbers

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5193    Accepted Submission(s): 1642

Problem Description
If we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number. You are required to count the number of good numbers in the range from A to B, inclusive.
 
Input
The first line has a number T (T <= 10000) , indicating the number of test cases. Each test case comes with a single line with two numbers A and B (0 <= A <= B <= 1018).
 
Output
For test case X, output "Case #X: " first, then output the number of good numbers in a single line.
 
Sample Input
2
1 10
1 20
 
Sample Output
Case #1: 0
Case #2: 1

Hint

The answer maybe very large, we recommend you to use long long instead of int.

 
Source
 

发现: 0-10    1

    0-100  10

0-1000   100

0-990  99

    0-992  100

    0-997   100

  基本规律为 n/10 + (1或0)

  加1的情况为:n/10*10 到 n  有满足条件的  比如:997: 99 + (990到997是否有满足条件的,如果有则加1)

hdu 4722 Good Numbers 规律 数位dp的更多相关文章

  1. HDU 4722:Good Numbers(数位DP)

    类型:数位DP 题意:定义一个Good Number 为 一个数所有位数相加的和%10==0.问[A,B]之间有多少Good Number. 方法: 正常“暴力”的定义状态:(i,d,相关量) 定义d ...

  2. HDU 4722 Good Numbers(位数DP)(2013 ACM/ICPC Asia Regional Online ―― Warmup2)

    Description If we sum up every digit of a number and the result can be exactly divided by 10, we say ...

  3. 找规律/数位DP HDOJ 4722 Good Numbers

    题目传送门 /* 找规律/数位DP:我做的时候差一点做出来了,只是不知道最后的 is_one () http://www.cnblogs.com/crazyapple/p/3315436.html 数 ...

  4. 【数位DP】 HDU 4722 Good Numbers

    原题直通车: HDU  4722  Good Numbers 题意: 求区间[a,b]中各位数和mod 10==0的个数. 代码: #include<iostream> #include& ...

  5. HDU - 4722 Good Numbers 【找规律 or 数位dp模板】

    If we sum up every digit of a number and the result can be exactly divided by 10, we say this number ...

  6. hdu 4722 Good Numbers( 数位dp入门)

    Good Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. hdu 4722 Good Numbers 数位DP

    数位DP!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include< ...

  8. HDU 4588 Count The Carries 数位DP || 打表找规律

    2013年南京邀请赛的铜牌题...做的非常是伤心.另外有两个不太好想到的地方.. ..a 能够等于零,另外a到b的累加和比較大.大约在2^70左右. 首先说一下解题思路. 首先统计出每一位的1的个数, ...

  9. HDU 5787 K-wolf Number (数位DP)

    K-wolf Number 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5787 Description Alice thinks an integ ...

随机推荐

  1. ES2019 / ES10有什么新功能?

    ECMAScript(简称ES)是ECMA International在ECMA-262和ISO / IEC 16262中标准化的脚本语言规范.它是为了标准化JavaScript语言而创建的,以便从浏 ...

  2. Oracle SQL常用内置系统函数总结

    Oracle数据库  内置系统函数主要分为以下类别:数学函数.字符串函数.日期函数.转换函数.聚合函数.分析聚合函数 一.数学函数 ------------返回数字       abs(n):返回数字 ...

  3. Permission 使用详解

    极力推荐文章:欢迎收藏 Android 干货分享 阅读五分钟,每日十点,和您一起终身学习,这里是程序员Android 本篇文章主要介绍 Android 开发中的部分知识点,通过阅读本篇文章,您将收获以 ...

  4. prometheus-kafka-exporter部署

    chart地址:https://gkarthiks.github.io/helm-charts/charts/prometheus-kafka-exporter/ 1.下载chart $ helm r ...

  5. Oracle RAC 集群启动与停止

    Oracle RAC 启动时,需要使用 root 用户执行,为了方便,写了启动和停止的脚本, 将该脚本放到 /root/bin ,因为bin 目录本身就在环境变量里,所以使用时直接root用户运行脚本 ...

  6. 【Java例题】7.6文件题3-文本文件统计

    6.文本文件统计.已有一个文本文件文件,请统计数字.大写字母.小写字母.汉字及其它字符出现的次数:然后将这些次数由大到小写到另一个文件之中.说明:将次数为零的过滤掉排序 package chapter ...

  7. iOS的录屏功能

    iOS的录屏功能其实没什么好说的,因为网上的教程很多,但是网上的Demo无一例外几乎都有一个bug,那就是iPad上会出现闪退,这也体现了国内的教程文档的一个特点,就是抄袭,教程几乎千篇一律,bug也 ...

  8. caddy & grpc(3) 为 caddy 添加一个 反向代理插件

    caddy-grpc 为 caddy 添加一个 反向代理插件 项目地址:https://github.com/yhyddr/caddy-grpc 前言 上一次我们学习了如何在 Caddy 中扩展自己想 ...

  9. java并发编程(九)----(JUC)CyclicBarrier

    上一篇我们介绍了CountDownlatch,我们知道CountDownlatch是"在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待",即CountDownL ...

  10. Mysql 局域网连接设置——Windows

    在公司工作中,会遇到mysql数据库存储于某个人的电脑上,大家要想连接mysql服务,装有mysql服务的电脑就必须开启远程连接. 其实不仅仅是局域网,只要你有数据库所在服务器的公网IP地址都能连上. ...