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. +----+-----+ | ...
随机推荐
- F - Free DIY Tour(动态规划,搜索也行)
这道题可用动态规划也可以用搜索,下面都写一下 Description Weiwei is a software engineer of ShiningSoft. He has just excelle ...
- 递推,大数存储E - Order Count
Description If we connect 3 numbers with "<" and "=", there are 13 cases: 1) ...
- sed学习笔记整理
1.sed简介 sed (Stream Editor)是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处 ...
- bresenham算法的FPGA的实现1
接着上一篇的 计算实现给出屏幕上任意两个点,求出这两个点之间直线上的所有的点.http://www.cnblogs.com/sepeng/p/4042464.html 这种直接算法的确是被鄙视了 强大 ...
- STRUTS2获得session和request
在struts1中,获得到系统的request或者session对象非常方便,都是按照形参传递的,但是在struts2中,request和session都被隐藏了struts提供两种方式访问sessi ...
- HDU 4679 String
String Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Total Sub ...
- Android PopupWindow显示位置和显示大小
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveGlhb3l1YW41MTE=/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...
- HTML5实现IP Camera网页输出
HTML5实现IP Camera网页输出 这两天做OA项目.有一个要通过IP Camera将视频流输出到浏览器端的模块.尽管如今买到的摄像头都会提供浏览器和client的实现,可是一般来说都是仅仅支持 ...
- [置顶] Android自定义控件大全
1,自定义Edittext, TextView,带底线的Edittext, TextView 2.自定义圆形ImageView,圆角ImageView 3,下拉刷新LinearLayout 4,多点触 ...
- CMake使用之一
概述 CMake是一个比make更高级的编译配置工具,它可以根据不同平台.不同的编译器,生成相应的Makefile或者vcproj项目. 通过编写CMakeLists.txt,可以控制生成的Makef ...