HDUOJ----Good Numbers
Good Numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 673 Accepted Submission(s): 242
The answer maybe very large, we recommend you to use long long instead of int.
#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的更多相关文章
- 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 ...
- 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. +----+-----+ | ...
- [LeetCode] Compare Version Numbers 版本比较
Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 &l ...
随机推荐
- C++获得本机所有网卡的IP和MAC地址信息
一台机器上可能不只有一个网卡,但每一个网卡只有一个MAC地址,而每一个网卡可能配置有多个IP地址:如平常的笔记本电脑中,就会有无线网卡和有线网卡(网线接口)两种:因此,如果要获得本机所有网卡的IP和M ...
- C# WCF 完整实例,winform 窗体作为 宿主
上一次提到,我们的WCF程序宿主是发布到IIS上面的.虽然这样做未尝不可,不过不便于我们进行“开始”或“停止”WCF服务的操作.所以再次尝试了编写以窗体应用程序作为WCF服务宿主的方式,并取得了成功. ...
- 提高你开发效率的十五个 Visual Studio 使用技巧
相信做开发的没有不重视效率的.开发C#,VB的都知道,我们很依赖VS,或者说,我们很感谢VS.能够对一个IDE产生依赖,说明这个IDE确实 有它的独特之处.无容置疑,VS是一个非常强大的IDE,它支持 ...
- python3之日期和时间(转载)
转载:https://www.cnblogs.com/zhangxinqi/p/7687862.html a = datetime.datetime.now() time.sleep(10) b = ...
- Jmeter-Maven-Plugin高级应用:Modifying Properties
Modifying Properties Pages 12 Home Adding additional libraries to the classpath Advanced Configurati ...
- 利用js_API 执行对html文档元素的属性的CRUD操作
转自:http://my.oschina.net/felay/blog/303470 <!DOCTYPE html> <html> <head> <meta ...
- Discuz常见小问题-修改了模块,如何重新移动原有模块的帖子
如果还能找到这个帖子(比如用搜索关键字的方法,我们看到他现在已经在CodeSys控制器的目录下,可以点击那个CodeSys控制器的超链接看到里面所有帖子),打开这个帖子之后可以点击移动,然后选择新的目 ...
- Office EXCEL VBA如何取得EXCEL中的行数和列数
VBA取得EXCEL表格中的行数和列数 请注意不要使用Columus等关键字作为变量,例如"Columus = ActiveSheet.UsedRange.Columns.Count&quo ...
- Java 吸血鬼数字
非常羞愧(事实上没什么羞愧.水平就这样).搞了半晌才写出来了一个Java 版求四位吸血鬼数字的方法 吸血鬼数字是指位数为偶数的数字.能够由一对数字相乘而得到.而这对数字各包括乘积的一半位数的数字,当中 ...
- PHP高级教程-Data
PHP date() 函数 PHP date() 函数用于格式化时间/日期. PHP date() 函数 PHP date() 函数可把时间戳格式化为可读性更好的日期和时间. 时间戳是一个字符序列,表 ...