HDUOJ #2089 不要62 /c++
来源:互联网 发布:矩阵扰动理论 编辑:程序博客网 时间:2024/06/16 04:01
车牌号
里面没有62和4
主要要点:
首先循环计算然后存储
以空间换时间,不然会超时
第二,n-m 用a[m]-a[n-1]而不是a[m]-a[n]
#include <iostream>#include<iomanip>#include <string>#include<math.h>using namespace std;int a[1000006];char t[10];int main(){int n,m;a[0]=0;for(int i=1;i<1000006;i++){int flag=1;memset(t,0,sizeof(t));itoa(i,t,10);for(int j=0;j<strlen(t);j++){if(t[j]=='4'||(t[j]=='6'&&t[j+1]=='2')){flag=0;break;}}if(flag){a[i]=a[i-1]+1;}else{a[i]=a[i-1];}}while(cin>>n>>m){if(n==0&&m==0){break;}cout<<a[m]-a[n-1]<<endl;}return 0;}
阅读全文
0 0
- HDUOJ 2089 - 不要62
- HDUOJ #2089 不要62 /c++
- HDUoj 2089 不要62(打表)(数位DP)
- HDUOJ 2089
- HDUOJ 2089 数位DP
- HDUOJ
- HDUoj
- hdu 2089 不要62
- HDOJ 2089 不要62
- hdu 2089 不要62
- hoj 2089不要62
- hdu 2089 不要62
- HDU 2089 不要62
- HDOJ 2089 不要62
- hdoj 2089 不要62
- HDU 2089 不要62
- HDU 2089 不要62
- hdu 2089 不要62
- android gps机制分析--之五
- cmake使用方法详解
- 数据库表的增加数据
- 概率论随机过程马氏链与平稳过程
- 1259: [CQOI2007]矩形rect
- HDUOJ #2089 不要62 /c++
- UVA 400 Unix ls
- Java如何实现跨平台
- 数据库使用过程中遇到的问题
- 各个版本spring的jar包以及源码下载地址
- leetcode 593: Valid Square
- Maximum Subarray
- notepad++配置python环境
- 数据库表的更新和修改数据