1. #include<iostream>
  2. #include<cstring>
  3. #include<cstdio>
  4. #include<vector>
  5. #include<queue>
  6. using namespace std;
  7. #define ll long long
  8. #define maxn 100050
  9. int ok(ll n){
  10. for(ll i=n/*;i<=n;i++){
  11. ll sum = ,tmp = i;
  12. while(tmp){
  13. sum += tmp%;
  14. tmp /= ;
  15. }
  16. if(sum% == ){
  17. return ;
  18. }
  19. }
  20. return ;
  21. }
  22. ll f(ll n){
  23. if(ok(n)){
  24. return (n/) + ;
  25. }
  26. return n/;
  27. }
  28. int main(){
  29. int T;
  30. cin >> T;
  31. for(int t=;t<=T;t++){
  32. ll n,m;
  33. cin >> n >> m;
  34. printf("Case #%d: %lld\n",t,f(m)-f(n-));
  35. }
  36. return ;
  37. }

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. MOCTF-Crypt-writeup

    MOctf Crypt Writeup记录 都不难,就随便记录记录下. MOCTF平台地址:http://www.moctf.com 0x01 数据库密码 hint:20岁的小刚,自幼热爱信息安全,一 ...

  2. java高并发系列 - 第23天:JUC中原子类,一篇就够了

    这是java高并发系列第23篇文章,环境:jdk1.8. 本文主要内容 JUC中的原子类介绍 介绍基本类型原子类 介绍数组类型原子类 介绍引用类型原子类 介绍对象属性修改相关原子类 预备知识 JUC中 ...

  3. 如何让传统ASP.NET网站在Docker中运行

    本文主要描述如何让传统ASP.NET网站在Docker中运行,侧重Docker image 搭建. 使用条件: Docker for windows 用户切换到Windows 容器模式 Windows ...

  4. Mybatis学习笔记之---环境搭建与入门

    Mybatis环境搭建与入门 (一)环境搭建 (1)第一步:创建maven工程并导入jar包 <dependencies> <dependency> <groupId&g ...

  5. Java泛型使用的简单介绍

    目录 一. 泛型是什么 二. 使用泛型有什么好处 三. 泛型类 四. 泛型接口 五. 泛型方法 六. 限定类型变量 七. 泛型通配符 7.1 上界通配符 7.2 下界通配符 7.3 无限定通配符 八. ...

  6. 基于Starling的mask实现

    作为一个从c++转过来的程序员,flash原生的自定义mask实在是太好用,能方便实现各种效果,比如新手引导的高亮.viewport效果等.可惜starling的显示对象并不支持mask特性,查阅go ...

  7. 【Aizu - 2249】Road Construction(最短路 Dijkstra算法)

    Road Construction Descriptions Mercer国王是ACM王国的王者.他的王国里有一个首都和一些城市.令人惊讶的是,现在王国没有道路.最近,他计划在首都和城市之间修建道路, ...

  8. testlink搭建教程

    1,下载testlink安装包   请加QQ群299524235,在群文件中下载     2.配置Apache环境和PHP环境   解压testlink文件到Apache中, 通过127.0.0.1/ ...

  9. 洛谷 P1177 【模板】快速排序

    这道题用传统快排(如下所示)的结果就是最后三个点TLE: void swap(int &a, int &b) { int tmp = a; a = b; b = tmp; } void ...

  10. R 实用命令 2

    1. how to temporarily unload the packages in R > library(Daim) 载入程辑包:‘Daim’ The following objects ...