hdu 4722 Good Numbers(规律题)
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(规律题)的更多相关文章
- hdu 4722 Good Numbers 规律 数位dp
#include<iostream> #include<cstring> #include<cstdio> #include<vector> #incl ...
- 【数位DP】 HDU 4722 Good Numbers
原题直通车: HDU 4722 Good Numbers 题意: 求区间[a,b]中各位数和mod 10==0的个数. 代码: #include<iostream> #include& ...
- HDU 4722 Good Numbers
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 Good Numbers Time Limit: 2000/1000 MS (Java/Othe ...
- HDU 4722 Good Numbers 2013年四川省赛题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 题目大意:给定一个区间,求区间中有多少个满足每位上的数的和是10的倍数. 解题思路:先打表暴力求 ...
- 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 ...
- 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 ...
- hdu 4722 Good Numbers( 数位dp入门)
Good Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tota ...
- HDU 4722 Good Numbers(DP)
题目链接 脑子有点乱,有的地方写错了,尚大婶鄙视了... 来个模版的. #include <iostream> #include <cstdio> #include <c ...
- hdu 4722 Good Numbers 数位DP
数位DP!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include< ...
随机推荐
- css3 边框记
css3 边框 border属性在css1中就已经定义了,使用它可以设置元素的边框风格,边框颜色以及边框粗细. border-width:设置元素边框的粗细. border-color:设置元素边框的 ...
- HTML+CSS3 纯代码实现转盘效果
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- Ehcache(2.9.x) - API Developer Guide, Basic Caching
Creating a CacheManager All usages of the Ehcache API start with the creation of a CacheManager. The ...
- Linux 命令 - cat: 合并文件至标准输出
命令格式 cat [OPTION]... [FILE]... 命令参数 -A, --show-all 等价于 -vET. -b, --number-nonblank 对非空输出行编号. -e 等价于 ...
- 【Knockout】四、绑定上下文
Binding context binding context是一个保存数据的对象,你可以在你的绑定中引用它.当应用绑定的时候,knockout自动创建和管理binding context的继承关系. ...
- 和阿文一起学H5--如何把H5压缩到最小
三种压缩图片的方法: 1.PS 但是PS每次只能压缩一张,下面介绍第二个神器 2.TinyPng压缩 https://tinypng.com/ 3.IloveIMG压缩 http://www.ilov ...
- 常用的sql标准建表语句
使用指定数据库 use v4base 建一张表 /*************************************************************************** ...
- 在win下面使用cdt+cygwin+cmake
在cygwin终端下面, cmake -G"Eclipse CDT4 - Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug 当收获警告 Could ...
- apktool反编译工具
几个报错的解决办法 apktool反编译时经常会出现下面的信息 Input file was not found or was not readable. Destination directory ...
- Js中的运算符
运算符 运算符:就是可以运算的符号 比如 + .-.*./ 运算符包括: 算术运算符 比较运算符 逻辑运算符 赋值运算符 字符串运算符 1.算术运算符 +.-.*./.%(求余数).++.-- ++: ...