hdu4722 Good Numbers
Good Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 45 Accepted Submission(s): 14
You are required to count the number of good numbers in the range from A to B, inclusive.
Each test case comes with a single line with two numbers A and B (0 <= A <= B <= 10
18).
1 10
1 20
Case #2: 1
The answer maybe very large, we recommend you to use long long instead of int.
#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的更多相关文章
- HDU4722——Good Numbers——2013 ACM/ICPC Asia Regional Online —— Warmup2
今天比赛做得一个数位dp. 首先声明这个题目在数位dp中间绝对是赤裸裸的水题.毫无技巧可言. 题目的意思是个你a和b,要求出在a和b中间有多少个数满足数位上各个数字的和为10的倍数. 显然定义一个二维 ...
- Java 位运算2-LeetCode 201 Bitwise AND of Numbers Range
在Java位运算总结-leetcode题目博文中总结了Java提供的按位运算操作符,今天又碰到LeetCode中一道按位操作的题目 Given a range [m, n] where 0 <= ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- [LeetCode] Add Two Numbers II 两个数字相加之二
You are given two linked lists representing two non-negative numbers. The most significant digit com ...
- [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 ...
- [LeetCode] Count Numbers with Unique Digits 计算各位不相同的数字个数
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Examp ...
- [LeetCode] Bitwise AND of Numbers Range 数字范围位相与
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers ...
- [LeetCode] Valid Phone Numbers 验证电话号码
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bas ...
- [LeetCode] Consecutive Numbers 连续的数字
Write a SQL query to find all numbers that appear at least three times consecutively. +----+-----+ | ...
随机推荐
- BZOJ 3236: [Ahoi2013]作业( 莫队 + BIT )
莫队..用两个树状数组计算.时间复杂度应该是O(N1.5logN). 估计我是写残了...跑得很慢... ----------------------------------------------- ...
- Tomcat 常规配置并通过zabbix 监控 jvm状态
一:jdk和tomcat基础 apache有两种方式运行php,一是使用模块,二是使用fastcgi nginx也可以通过fastcgi处理动态请求,也可以转发至tomcat tomcat监控主要是监 ...
- include与jsp:include区别
jsp 中include有两种形式,分别是 <%@ include file=” ”%> <jsp:include page=” ” flush=”true”/> 前者是指令元 ...
- mongoose 数据库操作 - 分页
使用mongoose 加入分页方法,临时还没发现什么更好的方法,我使用的方法是,直接在源代码中加入 找到 node_modules/mongoose/lib/model.js打开这个文件.里面加入这段 ...
- Codeforces Round #260 (Div. 2)C. Boredom(dp)
C. Boredom time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- C++sort函数使用总结
头文件:algorithm 对于(整数/字符)数组进行比較时,可直接通过sort(a,a+n)或sort(a.begin(),a.end())进行排序,默认升序排列,须要高速实现降序时,有三种方案 1 ...
- 闲扯 Javascript 00
引言 Javascript 的作用在此就不阐述了,相信你已经知道它的用途!那我说点什么呢? 不如就和大家先扯一把,后面的工作 随后后展开吧! 首先声明:我个人对Javascript 认识,我只知道它 ...
- 【转】linux下 postgres的一些操作总结
参考博文: PostgreSQL详解 1. 基本操作命令 安装完成后,PostgreSQL默认创建了名为postgres数据库用户账户,其与MySQL的root以及SQL Server的sa账 ...
- Python 第六篇(中):面向对象编程中级篇
面向对象编程中级篇: 编程思想概述: 面向过程:根据业务逻辑从上到下写垒代码 #最low,淘汰 函数式:将某功能代码封装到函数中,日后便无需重复编写,仅调用函数即可 #混口饭吃 def add(ho ...
- Handler.removeMessages的作用,有时候为什么一定要先remove一下呢
removeMessages会将handler对应message queue里的消息清空,如果带了int参数则是对应的消息清空.队列里面没有消息则handler会不工作,但不表示handler会停止. ...