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】:

  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int isOne(__int64 n) //例如:456计算450-456有没有符合条件的数
  9. {
  10. int s=;
  11. __int64 i=n/*;
  12. __int64 m = n;
  13. for(;i<=m;i++)
  14. {
  15. n=i;
  16. s=;
  17. while(n)
  18. {
  19. s+=n%;
  20. n/=;
  21. }
  22. if(s%==) return ;
  23. }
  24. return ;
  25. }
  26.  
  27. __int64 getNum(__int64 n)
  28. {
  29. if(n<) return ;
  30. if(n<=) return ;
  31. return n/+isOne(n);
  32. }
  33.  
  34. int main()
  35. {
  36. int t,cas=;
  37. scanf("%d",&t);
  38. while(t--)
  39. {
  40. __int64 a,b;
  41. scanf("%I64d%I64d",&a,&b);
  42. printf("Case #%d: %I64d\n",cas++,getNum(b)-getNum(a-));
  43. }
  44. return ;
  45. }

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. Windows 8.1 归档 —— Step 2 对新系统的少量优化

    下面是来自 iplaysoft 的优化技巧:

  2. 为Widget添加事件

      原帖:http://bbs.51cto.com/thread-965565-1-1.html 在appWidget中,ImageButton和Button都是被支持的控件,其事件可分成三种类型: ...

  3. html dom的加载

    操作HTML DOM文档的一个难题是,你的JavaScript代码可能在DOM完全载入之前运行,这会导致你的代码产生一些问题.页面加载时浏览器内部操作的顺序大致是这样的: 1. HTML被解析. 2. ...

  4. 第四篇、微信小程序-icon组件

    属性: 效果图: test.wxml <!--成功图标--> <icon type="success" size="40"/> < ...

  5. OC11_自动释放池

    // // Dog.h // OC11_自动释放池 // // Created by zhangxueming on 15/6/18. // Copyright (c) 2015年 zhangxuem ...

  6. IOS基础 Day-1手动内存管理

    辞职回家打算自学IOS开发,就在借个地方记录一下 Day-1      手动内存管理                   主要内容:release  retain必须配对好,不然会占用内存 慢慢积累导 ...

  7. (转)JVM参数调优八大技巧

    这里和大家分享一下JVM参数调优的八条经验,JVM参数调优,这是很头痛的问题,设置的不好,JVM不断执行FullGC,导致整个系统变得很慢,网站停滞时间能达10秒以上,相信通过本文的学习你对JVM参数 ...

  8. (转)Web2.0 大型互联网站点的架构

    这种资料.向来可遇不可求啊 WikiPedia 技术架构学习分享 http://www.dbanotes.net/opensource/wikipedia_arch.html YouTube 的架构扩 ...

  9. 20分钟入门Redux

    Redux就是个数据中心,不依附于任何框架在哪使用都行.但是和它最搭配的应该就是React了,而且大家学习它的动力大多也是解决React状态管理的问题.都说Redux文档详尽清晰,但我感觉并不友好,它 ...

  10. 【Leetcode】355. Design Twitter

    题目描述: Design a simplified version of Twitter where users can post tweets, follow/unfollow another us ...