Good Numbers

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

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
 找规律......
代码:
 #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#define LL _int64
#include<algorithm>
using namespace std;
LL cal(LL n)
{
LL num,i,j,ans,sum;
num=n/100;
ans=num*10;
for(i=num*100;i<=n;i++)
{
j=i;
sum=0;
while(j)
{
sum+=j%10; //将各个位相加
j/=10;
}
if(sum%10==0)
ans++;
}
return ans;
}
void Init()
{
LL l,r;
static int count=1;
scanf("%I64d%I64d",&l,&r);
LL temp=cal(r)-cal(l-1);
printf("Case #%d: %I64d\n",count++,temp);
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
Init();
}
return 0;
}

HDUOJ----Good Numbers的更多相关文章

  1. hduoj 4706 Herding 2013 ACM/ICPC Asia Regional Online —— Warmup

    hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup Herding Time Limit: 2000/1000 ...

  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. +----+-----+ | ...

  10. [LeetCode] Compare Version Numbers 版本比较

    Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 &l ...

随机推荐

  1. Android图片加载框架最全解析(四),玩转Glide的回调与监听

    大家好,今天我们继续学习Glide. 在上一篇文章当中,我带着大家一起深入探究了Glide的缓存机制,我们不光掌握了Glide缓存的使用方法,还通过源码分析对缓存的工作原理进行了了解.虽说上篇文章和本 ...

  2. 解决谷歌google不能访问造成wordpress打开缓慢的问题

    近日谷歌又不能访问了,开始没觉得有什么问题.对于技术控的我一直以来谷歌搜索是我的必备工具,这次似乎和往常不太一样,好几天了还是不能访问,通过修改hosts等办法还是没用,只有FQ出去才能访问,但总不能 ...

  3. csv2txt.cpp

    #include <iostream> #include <fstream.h> #include <windows.h> #include <iomanip ...

  4. 淘宝Tprofiler工具实现分析

    工具介绍TProfiler是一个可以在生产环境长期使用的性能分析工具.它同时支持剖析和采样两种方式,记录方法执行的时间和次数,生成方法热点 对象创建热点 线程状态分析等数据,为查找系统性能瓶颈提供数据 ...

  5. TRIZ理论的进化法则分析(TRIZ学习笔记)

    人们在创新和完好系统的过程能够遵循一定的规律(或者叫法则).从而降低创新和完好系统过程中的试错成本,以下就TRIZ的八大进化原则来进行说明(这个八大法则是前人们的总结,我这里当然会增加我的理解). 我 ...

  6. [转]一键安装藏隐患,phpStudy批量入侵的分析与溯源

    一.前言 近日,腾讯安全云鼎实验室监测到大量主机被入侵并添加了一个名为“vusr_dx$”的隐藏帐号:同时,云鼎实验室还监测到此类帐号被大量创建的同时存在对应帐号异地登录的情况. Windows 的帐 ...

  7. Page Redirect Speed Test

    现在,有两种方法可以实现网页的自动跳转. (1) 用html自带的<meta>标签(如下)可以实现网页的自动跳转,而且可以控制跳转的延时. <meta http-equiv=&quo ...

  8. C# 特性(Attribute)(一)

    特性(Attributes)是一种崭新的声明性信息.我们不仅可以通过特性来定义设计层面的信息(例如help file, URL for documentation)以及运行时(run-time)信息( ...

  9. RichTextBox 清空

    this.tbContent.Document.Blocks.Clear();

  10. .NET MVC自定义错误处理页面的方法

    在ASP.NET MVC中,我们可以使用HandleErrorAttribute特性来具体指定如何处理Action抛出的异常.只要某个Action设置了HandleErrorAttribute特性,那 ...