HDOJ 2089 不要62
来源:互联网 发布:200鼠标推荐知乎 编辑:程序博客网 时间:2024/05/16 11:39
题意:求m到n中不含4与62(连续)的数的个数
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2089
思路:数位DP(不会)或树状数组。树状数组:预处理,单点更新,区间查询
注意点:无
以下为AC代码:
Run IDSubmit TimeJudge StatusPro.IDExe.TimeExe.MemoryCode Len.LanguageAuthor129410052015-02-12 20:09:15Accepted208993MS4508K1524 BG++luminous11#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <vector>#include <deque>#include <list>#include <cctype>#include <algorithm>#include <climits>#include <queue>#include <stack>#include <cmath>#include <map>#include <set>#include <iomanip>#include <cstdlib>#include <ctime>#define ll long long#define ull unsigned long long#define all(x) (x).begin(), (x).end()#define clr(a, v) memset( a , v , sizeof(a) )#define pb push_back#define mp make_pair#define read(f) freopen(f, "r", stdin)#define write(f) freopen(f, "w", stdout)using namespace std;//const double pi = acos(-1);//const double eps = 1e-10;//const int dir[[4][2] = { 1,0, -1,0, 0,1, 0,-1 };int sum[1000005] = { 0 };bool calc ( int num ){ while ( num ){ if ( ( num % 100 == 62 || num % 10 == 4 ) ) return false; else num /= 10; } return true;}void add ( int k, int num ){ for ( ; k < 1000005; k += ( k & ( -k ) ) ) sum[k] += num;}int query ( int k ){ int ans = 0; for ( ; k > 0; k -= ( k & ( -k ) ) ) ans += sum[k]; return ans;}int main(){ ios::sync_with_stdio( false ); int m, n; for ( int i = 1; i < 1000005; i ++ ){ if ( calc ( i ) ){ add ( i, 1 ); } } while ( cin >> m >> n ){ if ( m == 0 && n == 0 )break; cout << query ( n ) - query ( m - 1 ) << endl; } return 0;}
0 0
- HDOJ 2089 不要62
- HDOJ 2089 不要62
- hdoj 2089 不要62
- HDOJ 2089 不要62
- 不要62 hdoj 2089
- HDOJ 2089 不要62
- HDOJ 2089 不要62
- hdoj 2089 不要62
- HDOJ 2089 不要62
- 【HDOJ 2089】不要62
- HDOJ--2089--不要62
- hdoj-2089-不要62
- HDOJ-2089 不要62
- HDOJ 2089 不要62
- hdoj 2089 不要62
- HDOJ 2089 不要62
- hdoj-【2089 不要62】
- HDOJ.2089 不要62
- 关于MongoDB事务
- 第17周项目电子词典结构体版
- JAVA中的23种设计模式
- 蓝牙4.0防丢器开发中遇到的问题
- [LeetCode]Balanced Binary Tree
- HDOJ 2089 不要62
- 作为人才我们为什么要和几个猎头保持良好的关系?
- iOS 关于UIView的各种判断
- ios UIViwe动画
- Android 开发--CSDN博客大神汇总
- ISIS_Proposal安装
- Mathematica描绘滚球某个点的运动轨迹(摆线)
- 【Android开发经验】Android开发相关的Blog推荐——跟随大神的脚步才能成长为大神
- 深入分析 Java 中的中文编码问题