http://acm.hdu.edu.cn/showproblem.php?pid=4722

【题意】:

  找GoodNumbers一个数N,如果它每一个位数字之和可以整除10,那么它就是GoodNumbers,比如451就是一个4+5+1=10,求[A,B]之间这样的数的个数

【题解】:

  先写一个暴力代码用来找规律

发现: 0-10    1

    0-100  10

0-1000   100

0-990  99

    0-992  100

    0-997   100

  基本规律为 n/10 + (1或0)

  加1的情况为:n/10*10 到 n  有满足条件的  比如:997: 99 + (990到997是否有满足条件的,如果有则加1)

【code】:

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm> using namespace std; int isOne(__int64 n) //例如:456计算450-456有没有符合条件的数
{
int s=;
__int64 i=n/*;
__int64 m = n;
for(;i<=m;i++)
{
n=i;
s=;
while(n)
{
s+=n%;
n/=;
}
if(s%==) return ;
}
return ;
} __int64 getNum(__int64 n)
{
if(n<) return ;
if(n<=) return ;
return n/+isOne(n);
} int main()
{
int t,cas=;
scanf("%d",&t);
while(t--)
{
__int64 a,b;
scanf("%I64d%I64d",&a,&b);
printf("Case #%d: %I64d\n",cas++,getNum(b)-getNum(a-));
}
return ;
}

hdu 4722 Good Numbers(规律题)的更多相关文章

  1. hdu 4722 Good Numbers 规律 数位dp

    #include<iostream> #include<cstring> #include<cstdio> #include<vector> #incl ...

  2. 【数位DP】 HDU 4722 Good Numbers

    原题直通车: HDU  4722  Good Numbers 题意: 求区间[a,b]中各位数和mod 10==0的个数. 代码: #include<iostream> #include& ...

  3. HDU 4722 Good Numbers

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 Good Numbers Time Limit: 2000/1000 MS (Java/Othe ...

  4. HDU 4722 Good Numbers 2013年四川省赛题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 题目大意:给定一个区间,求区间中有多少个满足每位上的数的和是10的倍数. 解题思路:先打表暴力求 ...

  5. HDU - 4722 Good Numbers 【找规律 or 数位dp模板】

    If we sum up every digit of a number and the result can be exactly divided by 10, we say this number ...

  6. HDU 4722 Good Numbers(位数DP)(2013 ACM/ICPC Asia Regional Online ―― Warmup2)

    Description If we sum up every digit of a number and the result can be exactly divided by 10, we say ...

  7. hdu 4722 Good Numbers( 数位dp入门)

    Good Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  8. HDU 4722 Good Numbers(DP)

    题目链接 脑子有点乱,有的地方写错了,尚大婶鄙视了... 来个模版的. #include <iostream> #include <cstdio> #include <c ...

  9. hdu 4722 Good Numbers 数位DP

    数位DP!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include< ...

随机推荐

  1. hdu 4614 线段树

    思路:当k为1的时候,用二分法查询包含有f个空瓶的上界r,然后更新会方便很多,直接更新区间(a,r)了. #include<iostream> #include<cstdio> ...

  2. InternetOpen怎么使用代理

    如果你用IE的默认代理设置:hinternet=InternetOpen(AfxGetAppName(),INTERNET_OPEN_TYPE_PROXY,NULL,NULL,0); 把INTERNE ...

  3. 面试之BI-SQL--table转换[2]

    month   salesPerMonth 1 2 2 3 3 2 4 4 5 3 6 3                                 写条SQL语句把上表转成下表: month  ...

  4. 面试之SQL(2)--left join, inner join 和 right join的区别

    表A记录如下: aID        aName 1           a1 2           a2 3           a3 4           a4 5           a5 ...

  5. .net 获取网站根目录总结

    一.获取网站根目录的方法有几种如: Server.MapPath(Request.ServerVariables["PATH_INFO"]) //页面详细路 Server.MapP ...

  6. 两种查看eclipse或MyEclipse是64bit还是32bit的方法

    方法一: 对于:eclipse 打开eclipse后:Help-->About Eclipse-->Installation Details-->Configuration 如果看到 ...

  7. 关于web上的图片格式问题,新的彩蛋

    我们耳熟能详的几种格式无外乎 png-8,png-24,jpeg,gif,svg. 但是上面的那些都不是能够另人惊喜的答案.关于新技术的是Webp,Apng.(是否有关注新技术,新鲜事物) 1)Web ...

  8. 深度探索C++对象模型读书笔记(2)

    以下测试平台均为vs 2012 指向Data Member的指针测试(1) #include <stdio.h> class Base1 { public: int val1; int v ...

  9. Windows Phone 为指定容器内的元素设置样式

    在Windows Phone中设置元素样式有多种 拿TextBlock来说 1.我们可以直接在控件上设置: <TextBlock Text="自身样式设置" Width=&q ...

  10. mysql table readonly

    if the table does not have primary key or unique non-nullable defined, then MySql workbench could no ...