Good Numbers

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

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 <= 10
18).
 
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
 
Recommend
zhuyuanchen520
找规律题,水题!
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
__int64 ff(__int64 m)
{
if(m<0)
return 0;
__int64 temp=m/100,ans;
__int64 i;
ans=temp*10;
for(i=temp*100;i<=m;i++)
{
__int64 sum=0,t=i;
while(t)
{
sum+=t%10;
t/=10;
}
if(sum%10==0)
ans++;
}
return ans;
}
int main()
{
int tcase ,tt=1;
__int64 a,b;
scanf("%d",&tcase);
while(tcase--)
{
scanf("%I64d%I64d",&a,&b);
printf("Case #%d: %I64d\n",tt++,ff(b)-ff(a-1));
}
return 0;
}

hdu4722 Good Numbers的更多相关文章

  1. HDU4722——Good Numbers——2013 ACM/ICPC Asia Regional Online —— Warmup2

    今天比赛做得一个数位dp. 首先声明这个题目在数位dp中间绝对是赤裸裸的水题.毫无技巧可言. 题目的意思是个你a和b,要求出在a和b中间有多少个数满足数位上各个数字的和为10的倍数. 显然定义一个二维 ...

  2. Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range

    在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ...

  3. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  4. [LeetCode] Add Two Numbers II 两个数字相加之二

    You are given two linked lists representing two non-negative numbers. The most significant digit com ...

  5. [LeetCode] Maximum XOR of Two Numbers in an Array 数组中异或值最大的两个数字

    Given a non-empty array of numbers, a0, a1, a2, … , an-1, where 0 ≤ ai < 231. Find the maximum re ...

  6. [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数

    Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...

  7. [LeetCode] Bitwise AND of Numbers Range 数字范围位相与

    Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...

  8. [LeetCode] Valid Phone Numbers 验证电话号码

    Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...

  9. [LeetCode] Consecutive Numbers 连续的数字

    Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | ...

随机推荐

  1. 完整的RecylerView的使用方法和例子

       一.RecylerView的特点 1. 不关心Item是否显示在正确的位置,通过设置不同LayoutManager 的实例让Item显示不同的风格. 2. 不关心 Item间如何分离.要定义It ...

  2. ftp上传错误

    明明设置好了权限,但是在上传的时候提示如下错误,但在使用的过程当中,发现有的时候是可以上传的,很奇怪的问题. baidu 了一下,发现是下面的这个设置导致的.改过来后,果然正常. 这个设置只是一个字符 ...

  3. linux下安装greenplum

    1. 下载 Greenplum Database 源代码 $ git clone https://github.com/greenplum-db/gpdb 2. 安装依赖库 Greenplum Dat ...

  4. pChart图表插件使用

    <?php /* 柱形图 */ #引入库文件 include("../class/pData.class.php"); include("../class/pDra ...

  5. [概率dp] ZOJ 3822 Domination

    题意: 给N×M的棋盘.每天随机找一个没放过棋子的格子放一个棋子 问使得每一个每列都有棋子的天数期望 思路: dp[i][j][k] 代表放了i个棋子占了j行k列 到达目标状态的期望 然后从 dp[n ...

  6. Amazon的AWS账单看起来不是很方便

    发了一个PDF格式的收据,只写了收取的费用,EC2下面的明细没有. DetailAmazon Simple Notification Service $0.00Charges $0.00Estimat ...

  7. C语言宏定义技巧

    出处:http://blog.chinaunix.net/uid-14022540-id-2849095.html 1.宏中"#"和"##"的用法 一.一般用法 ...

  8. LVS集群的体系结构

    2.LVS主要组成部分为: 负载调度器(load balancer/ Director),它是整个集群对外面的前端机,负责将客户的请求发送到一组服务器上执行,而客户认为服务是来自一个IP地址(我们可称 ...

  9. ZOJ 3492 模拟循环链表线性查找

    WA了好几次最后找到错因是因为数组开小了! = = string whose length never exceeds 20 所以至少要开到21 = = ,我却一直开20 ╮(╯▽╰)╭ AC代码: ...

  10. 04-IOSCore - User Defaults、Archive、存储总结

    一. User Defaults 1. 是什么? 是一个特殊的plist文件 2. 干什么? 用于保存应用的配置信息 3. 存什么信息? 信息:欢迎界面有没有被打开过 目的:欢迎界面只显示一次 信息: ...